相关疑难解决方法(0)

当`PostAuthenticateRequest`被执行时?

这是我的Global.asax.cs档案:

public class MvcApplication : System.Web.HttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        ...
    }

    protected void Application_Start()
    {
        this.PostAuthenticateRequest += new EventHandler(MvcApplication_PostAuthenticateRequest);
    }

    // This method never called by requests...
    protected void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e)
    {
        HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

        if (authCookie != null)
        {
            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            var identity = new GenericIdentity(authTicket.Name, "Forms");
            var principal = new GenericPrincipal(identity, new string[] { });
            Context.User = principal;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

什么时候PostAuthenticateRequest执行?

.net c# asp.net asp.net-mvc-2

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

.net ×1

asp.net ×1

asp.net-mvc-2 ×1

c# ×1