开发者

ASP.NET - TTL on Session Key-Value-Pairs (InProc)

Is there a sanctioned method for adding TTL to ASP.开发者_开发技巧NET InProc Session State entries?

Example:

Session("First", 60) = "John"
Session("Adams", 500) = "Adams"


Out of the box, no there isn't. Individual Session State Key-Value-Pairs do not have any built-in method for adding a TTL or TTE.

Regarding the "global" InProc session state-timeout, it is controlled by a session state wide value configured in your web.config file (the timeout value in the /system.web/sessionState settings).

Additionally, whilst it may look like an attractive proposition to create your own session state provider, you couldn't use the Session property exposed by the page or controller code as this returns a HttpSessionState object. None of the methods, properties or indexers support having an extra parameter to specify individual session value timeouts.

You may consider doing the following:

  • Maintain an active session for each user:

    Session("PersistMe") = true

  • Grab SessionID, and use it to store values in the ASP.NET Cache where you may utilize a TTL value.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜