Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET Authentification fails with IE 10
    text
    copied!<p>today I've encountered with strange issue. My site was running on application pool under .NET 4 and today we noticed that it can't authenticate users under IE 10 (with other browsers everything is ok). Here's the exception that was thrown: </p> <blockquote> <p>Server Error in '/' Application.</p> <p>Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Security.FormsIdentity'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Security.FormsIdentity'.</p> </blockquote> <p>But after upgrading .NET 4 to version 4.5 error has gone away. The strange thing is that we didn't change the version of .NET on application pool, it is still .NET 4.</p> <p>By the way I'm using custom principal and I'm attaching userData to AuthenticationTicket. Here's my code from the Global.asax:</p> <pre><code>protected void Application_PostAuthenticateRequest(object sender, EventArgs e) { HttpCookie authCooke = Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCooke != null) { FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCooke.Value); if (authTicket != null) { var identity = new GenericIdentity(authTicket.Name, "Forms"); var principal = new CustomPrincipal(identity); string userData = ((FormsIdentity)(Context.User.Identity)).Ticket.UserData; var serializer = new JavaScriptSerializer(); principal.User = (User)serializer.Deserialize(userData, typeof(User)); Context.User = principal; Thread.CurrentPrincipal = principal; } } } </code></pre> <p>Could anybody explain to me what I am doing wrong and how updating version of .NET without changing it on application pool could affect the site?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload