ASP.NET MVC 1 using persistent cookie, intercept loading of user data to include other logic

若如初见. 提交于 2019-12-11 10:47:07

问题


I am using Forms Authentication for the default MVC site, and i also have a custom DB table with extra user information (LINQ2SQL). I have some logic that loads the extra data from the db when the user logs in manually on the site, but the same logic is not executed when the users data is loaded from the persistent cookie stored when they logged in last.

At what point is that users data loaded, and how do i add my own logic during that event?


回答1:


IN your global.asax you can hook into the PostAuthenticateRequest event.

http://msdn.microsoft.com/en-us/library/system.web.httpapplication.postauthenticaterequest.aspx

    protected void Application_Start()
    {

    }

    protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
    {
        //do stuff with User.Identity here
    }


来源:https://stackoverflow.com/questions/1947413/asp-net-mvc-1-using-persistent-cookie-intercept-loading-of-user-data-to-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!