Created
June 4, 2012 13:33
Global.asax handle Application_AuthenticateRequest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_AuthenticateRequest(Object sender, EventArgs e) | |
{ | |
if (HttpContext.Current.User == null) return; | |
if (!HttpContext.Current.User.Identity.IsAuthenticated) return; | |
var id = HttpContext.Current.User.Identity as FormsIdentity; | |
if (id == null) return; | |
FormsAuthenticationTicket ticket = id.Ticket; | |
string userData = ticket.UserData; | |
string[] roles = userData.Split(','); | |
HttpContext.Current.User = new GenericPrincipal(id, roles); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment