How is session object timeout handled in ASP.NET with SQLServer as sessionState mode?

放肆的年华 提交于 2019-12-10 15:55:20

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/5553558/how-is-session-object-timeout-handled-in-asp-net-with-sqlserver-as-sessionstate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!