asp.net sessionID changing on postbacks?

后端 未结 2 1737
无人及你
无人及你 2021-01-18 04:34

I am writing an asp.net app that stored an object in cache. When the page loads the first time, it checks the cache for the object, if it is there, it will use the object. i

相关标签:
2条回答
  • 2021-01-18 05:05

    I think i just found my answer from MSDN (this is a change to 2.0,3.5):

    "When using cookie-based session state, ASP.NET does not allocate storage for session data until the Session object is used. As a result, a new session ID is generated for each page request until the session object is accessed. If your application requires a static session ID for the entire session, you can either implement the Session_Start method in the application's Global.asax file and store data in the Session object to fix the session ID, or you can use code in another part of your application to explicitly store data in the Session object."

    http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.sessionid.aspx

    0 讨论(0)
  • 2021-01-18 05:26

    The session id shouldn't be changing on postbacks. It is used by asp.net to do a similar thing. Can you provide more info on the scenario? what type of data, why/when are you trying to "cache"

    Update 1: Regarding it changing on each post back, have you disabled cookies? which version of asp.net are you using?

    0 讨论(0)
提交回复
热议问题