开发者

ASP.NET MVC 3: Session and Forms Authentication

开发者 https://www.devze.com 2023-03-26 08:50 出处:网络
i have asp.net mvc 3 site with Forms Authentication and Session with SQLServer mode. Today I try to set authentication mode=\"None\" and store auth-token in cookie (because authorization token i get f

i have asp.net mvc 3 site with Forms Authentication and Session with SQLServer mode. Today I try to set authentication mode="None" and store auth-token in cookie (because authorization token i get from remote service) and check is cookie exist at Application_BeginRequest in global.asax, if no - user redirected to logon page. After authetication I store user in session: HttpContext.Current.Session[userToken]. When I set authentication mode="None" at first look it works as expected - user redirected to logon, s开发者_如何学JAVAubmit form with login and password and after that, on next request HttpContext.Current.Session is null. I don't know why it becomes null?


When you are accessing the Session[userToken] in the BeingRequest event of your Request pipeline, The Session has not been loaded yet.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号