protected void Application_AuthenticateRequest(object sender, EventArgs e) { if (HttpContext.Current.User != null) { if (HttpContext.Current.User.Identity.IsAuthenticated) { if (HttpContext.Current.User.Identity is FormsIdentity) { var identity = (FormsIdentity)HttpContext.Current.User.Identity; var ticket = identity.Ticket; var userData = CookieHelper.DecodeUserData(ticket.UserData); var role = userData.Role; HttpContext.Current.User = new GenericPrincipal(identity, new[] { role }); } } } }