ASP.NET MVC 4会话超时 [英] ASP.NET MVC 4 Session timeout

查看:160
本文介绍了ASP.NET MVC 4会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发与ASP.NET MVC4使用VS 2012的互联网应用程序,IIS 7.5。我使用窗体身份验证的相同。在我的web配置的设置如下:

I am developing an Internet app with ASP.NET MVC4 using VS 2012, IIS 7.5. I am using Forms Authentication for the same. The settings in my web config is as follows.

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login" timeout="30" name="userInfo" slidingExpiration="true" enableCrossAppRedirects="false" protection="All" >
    <credentials passwordFormat="Clear"/>
  </forms>
</authentication>

但空闲超时(分)在IIS中设置为20。当我20多分钟,我得到一个错误说我的会话对象之一为空后刷新我的申请。但是,如果我刷新我的应用程序30分钟后,它做工精细,它重定向我到登录页面。进入凭据后,我适当地导航到相应的页面。

But the Idle Timeout (minutes) setting in IIS is 20. When I refresh my application after 20+ minutes I am getting an error saying one of my session objects is null. But if I refresh my app after 30 minutes, it is working fine, that it is redirecting me to the login page. After entering the credentials, I am navigated properly to the appropriate page.

我不理解为什么我在20分钟后收到错误! (这是IIS空闲时间设置,据我所知)。请帮助。

I am not understanding why I am getting an error after 20 minutes! (which is the IIS idle time settings as far as I know). Please help.

感谢

推荐答案

窗体身份验证不处理会话超时。要调整会话状态超时代替。 MSDN 的具有纸幅的sessionState元素上的文章。配置更多的细节。

The forms authentication does not handle session timeout. You want to adjust the Session State timeout instead. MSDN has an article on the sessionState element of the web.config for more details.

如果你将要使用的会话状态,我会在不同的供应商阅读起来。如果你想扩展您的应用程序超越单一的Web服务器,你将要使用不同的会话提供比InProc方式之一。使用进程外会话提供的要求对象可序列化,这将可能是一个重大更改之后。做出改变现在保存自己头疼更高版本。

If you are going to be using the Session State, I would read up on the different providers. If you ever want to scale your application beyond a single web server, you will want to use a different session provider than the InProc one. Using an out of process session provider requires objects be serializable which will likely be a breaking change later. Make the change now to save yourself headaches later.

这篇关于ASP.NET MVC 4会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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