private void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e) { try { var authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie == null) { return; } var encTicket = authCookie.Value; if (string.IsNullOrEmpty(encTicket)) { return; } var ticket = FormsAuthentication.Decrypt(encTicket); var identity = SecurityUtilities.FormsAuthenticationTicketToIdentity(ticket); var principal = new CustomPrincipal(identity); HttpContext.Current.User = principal; // for Web Thread.CurrentPrincipal = principal; // for Back-end } catch { // ignored } }