开发者

Is it possible to see running time of an asp.net session?

I hav开发者_JAVA百科e a session variable and it is set default time of 20 minutes... Is it possible to see the running time of that session variable (ie) say 14 min 35 sec..


If you are already in the codebehind, your session will always be renewed to the specified timeout as the request has already been processed. The same goes for FormsAuthentication ticket, to some degree, depending on the sliding expiration settings.

The only valid use case for auditing session/ticket timeout is in an AJAX scenario.

Auditing session and/or forms ticket lifetime is a tricky proposition because you have to go to the server to access the httpOnly cookie in order to determine the timeout which, in most any scenario, results in refreshing the cookie/ticket leaving you with a catch 22 which results in a never ending session.

I have developed a solution to this problem using a custom HttpModule that exposes 2 virtual endpoints that returns a value representing the remaining life of the session/ticket. You can access these endpoints from javascript or managed code.

Find the implementation and example solution here: AsynchronousSessionAuditor

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜