Thread.CurrentPrincipal set in Application_AuthenticationRequest is not set later in the app
- 阅读更多 关于 Thread.CurrentPrincipal set in Application_AuthenticationRequest is not set later in the app
In the global.asax file for the Application_AuthenticationRequest I'm setting the Thread.CurrentPrincipal to a custom principal. I also set the HttpContext.Current.User to the same principal. However later in the app when I need to cast the Thread.CurrentPrincipal to our custom type, I get a runtime error saying: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'OurCustomPrincipal'. How did the Thread.CurrentPrincipal get reset to RolePrincipal, and more to the point how do I keep it at the CustomPrincipal we set in the global.asax Thanks in advance You surely have