ASP.NET SessionState timeout

2019-08-06 11:12发布

I use ASP.NET website on IIS7 where in web.config I have:

<sessionState mode="InProc" timeout="20"></sessionState>

But session doesn't keep 20 minutes, it works very strange, sometimes it expires in 1 minute or less, sometimes just redirect to other page. I need use mode="InProc".

Who can help me, what is wrong and how to resolve this problem? Thanks!

3条回答
Bombasti
2楼-- · 2019-08-06 11:37

If you have an application that is throwing unhandled exceptions, the application could recycle. Or, it could recycle because of memory pressure or even just from the wrong settings in IIS. This would cause you to lose session. You can put some logging code in the Application_End Eventhandler in global.asax to check for this condition.

查看更多
你好瞎i
4楼-- · 2019-08-06 11:54

Application Pool Recycling? (IIS setting).

Anyway, you can detect and handle the timeout in the global.asax (session_end), if that helps.

查看更多
登录 后发表回答