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 开发者_Python百科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?
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
}
精彩评论