Pergunta

Problem: In the ASP.NET Web Forms app Session_ID is different for every single Web request. Related ASP.NET_SessionId cookie is not appearing in the firebug.

While researching I found out that Session Cookie disappears right before PostReleaseRequestState event is fired.

Currently found a solution that customizes session-state module implementation. See SessionStateUtility Class (MSDN). While adopted to the app this sample seems to fix all the known problems but this solution is just not clean enough as for me, isn't it? If so what can be a problem here?

Related config source part looks like:
<sessionState mode="InProc" stateConnectionString="***" sqlConnectionString="***" cookieless="false" timeout="20"/>

Thanks.

Foi útil?

Solução

As documented in this answer https://stackoverflow.com/a/2874174/741695, ASP .NET does not allocate storage for session data until the session object is used.

In short, you can either implement Session_Start in Global.asax and store some dummy data in the Session object to fix its SessionID or you cna do the same somewhere else in your application code.

Hope this helps.

References:

https://stackoverflow.com/a/2874174/741695

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top