Exemple #1
0
        protected void Application_PostAuthenticateRequest()
        {
            HttpCookie authoCookies = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authoCookies != null)
            {
                try {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authoCookies.Value);
                    JavaScriptSerializer      js     = new JavaScriptSerializer();
                    User        user        = js.Deserialize <User>(ticket.UserData);
                    MyIdentity  myIdentity  = new MyIdentity(user);
                    MyPrincipal myPrincipal = new MyPrincipal(myIdentity);
                    HttpContext.Current.User = myPrincipal;
                }
                catch (CryptographicException cex)
                {
                    FormsAuthentication.SignOut();
                }
            }
        }
 public MyPrincipal(MyIdentity _myIdentity)
 {
     MyIdentity = _myIdentity;
 }