在 SQLServer 作为 sessionState 模式的 ASP.NET 中,如何处理会话对象超时?
当您将 SQL Server 设置为 ASP.NET 应用程序中的状态处理程序时,如何或在何处处理会话超时?
是.NET框架在从数据库加载会话对象后判断对象是否过期,还是SQL Server本身负责处理这个问题?我怀疑(甚至考虑)后一种可能性的原因是创建 ASPState 的脚本提到了有关 ASPState_Job_DeleteExpiredSessions 元素的内容。
如果是 SQL Server 作业进行清理,那么该作业多久触发一次以及它如何与 web.config 中的超时参数保持一致?
How, or maybe where, is the session timeout handled when you set SQL Server as state handler in an ASP.NET application?
Is it the .NET framwork who after loading session objects from the DB does a judgement on whether or not the objects are expired, or is it a job on the SQL Server itself that takes care of this? The reason I suspect (or even concidered) the latter possibility, is that the script that created the ASPState mentioned something about a ASPState_Job_DeleteExpiredSessions-element.
If it is so that it is an SQL Server job that cleans up, how often does this job trigger and how does it align with the timeout parameter in web.config?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 Quantum Elf 链接到的文章:
SqlSessionStateStore不主动监控 Expires 字段。相反,它依赖外部代理来清理数据库并删除过期会话(Expires 字段保存的日期和时间小于当前日期和时间的会话)。 ASPState 数据库包含一个 SQL Server 代理作业,该作业定期(默认情况下每 60 秒)调用存储过程 DeleteExpiredSessions 来删除过期会话。
这意味着由 SQL Server 处理过期和会话对象清除,并且特别是 SQL 作业代理。
From the article linked to by Quantum Elf:
SqlSessionStateStore doesn't actively monitor the Expires field. Instead, it relies on an external agent to scavenge the database and delete expired sessions—sessions whose Expires field holds a date and time less than the current date and time. The ASPState database includes a SQL Server Agent job that periodically (by default, every 60 seconds) calls the stored procedure DeleteExpiredSessions to remove expired sessions.
This means that it's the SQL Server that handles expriation and session object purging, and the SQL Job Agent in particular.
无论您是在进程内进行状态还是将其存储在 SQL Server 中,ASP.NET 会话状态超时仍会在 web.config/machine.config 中进行配置。
The ASP.NET session state timeout is still configured in web.config/machine.config regardless of whether you do state in-process or store it in SQL Server.