views:

182

answers:

1

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  A: 

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
    }
mcintyre321
i tried your suggestions, but the event doesn't fire when the site is loaded in a clean browser session when the persistent cookie is being used. The user is logged in, but my custom code is not executed.
Jason Miesionczek
I've changed snippet. Can you try it now?
mcintyre321
ok that worked, but my problem now is that the Session state is not available yet. Any thoughts on how i could work around that?
Jason Miesionczek
Session is not initialized until the AcquireRequestState event i think
mcintyre321