SQL Server会话状态的Session_End()替代方案 [英] Session_End() alternatives for SQL Server session state
问题描述
我在MVC4中有一个应用程序,该应用程序在Global.aspx.cs
中的Session_End()
方法中具有一些逻辑.
I have an application in MVC4 which has some logic in the Session_End()
method in Global.aspx.cs
.
但是,我需要将会话状态从InProc
更改为SQLServer
,这意味着将不会调用Session_End()
方法.
However, I need to change the session state from InProc
to SQLServer
, and this means the Session_End()
method will not get called.
I've tried to effect a workaround but I couldn't get it to work.
Session_End()
有哪些替代方案(如果有)?我需要的是能够在会话超时时运行一些逻辑.
What are the alternatives, if any, to Session_End()
? All I need is the ability to run some logic when the session times out.
推荐答案
当SessionState
处于SQLServer
模式时,会话不会超时.
The session doesn't time out when SessionState
is in SQLServer
mode.
从会话状态模式:
SQLServer 模式将会话状态存储在SQL Server数据库中.这样可以确保在重新启动Web应用程序后保留会话状态,并使会话状态可用于Web场中的多个Web服务器.
SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
这篇关于SQL Server会话状态的Session_End()替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!