ASP.NET MVC 1使用永久性Cookie,用户数据的拦截加载到其他逻辑 [英] ASP.NET MVC 1 using persistent cookie, intercept loading of user data to include other logic

查看:398
本文介绍了ASP.NET MVC 1使用永久性Cookie,用户数据的拦截加载到其他逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用窗体身份验证默认MVC网站,我也有额外的用户信息(LINQ2SQL)的自定义数据表。我在当用户的数据是从当他们在最近一次登录存储持久性cookie加载不执行手动在网站上的用户登录,但同样的逻辑加载从数据库中额外的数据一些逻辑。

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?

推荐答案

在您的Global.asax你可以连接到PostAuthenticateRequest事件。

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

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.httpapplication.postauthenticaterequest.aspx\" rel=\"nofollow\">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
    }

这篇关于ASP.NET MVC 1使用永久性Cookie,用户数据的拦截加载到其他逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆