MrMistreater

Global.asax handle Application_AuthenticateRequest

Apr 24th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. protected void Application_AuthenticateRequest(Object sender, EventArgs e)
  2. {
  3.     if (HttpContext.Current.User == null) return;
  4.     if (!HttpContext.Current.User.Identity.IsAuthenticated) return;
  5.     var id = HttpContext.Current.User.Identity as FormsIdentity;
  6.     if (id == null) return;
  7.  
  8.     FormsAuthenticationTicket ticket = id.Ticket;
  9.     string userData = ticket.UserData;
  10.     string[] roles = userData.Split(',');
  11.     HttpContext.Current.User = new GenericPrincipal(id, roles);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment