Pergunta

Due to an unknown reason, my website does not send ASP.NET_SessionId cookie to browser neither on local debugging IIS nor on deploying IIS, therefore my Session is always empty on each page. In IIS preferences 'Session state' is set to 'In process' (sorry, maybe not exact translation, I have localized IIS). Any ideas on this matter?

ADDITION 1: Well, I switched sessionState mode to <sessionState cookieless="UseUri" />. Url address in browser now contains (S(fn215g55r4kws155lbfaxf55)) tag, but Session property of the ASPX page is empty ANYWAY. So... my website is still sessionless without any obvious reason.

ADDITION 2. I created blank website on the same debug server and session cookie works okay there - values are persisted between calls. So, the problem is related to my main website or its web.config, I believe.

ADDITION 3. As mentioned @Damien_The_Unbeliever, the problem is really related to setting values. I do not know why, but session is completely ignores line Context.Session[promoCodeSessionKey] = (int?)promoCode.Id;. No cookie is send after this line. But if session is already created in another place and cookie is set, this line will work correctly.

ADDITION 4. I found the reason. See the answer below.

Foi útil?

Solução

WOOHOO!! I found the reason! There was EnableSessionState="ReadOnly" directive in ASPX's <%@ Page tag. Please pay attention, that a) because of this Session was not working on master page as well, and b) there are no exceptions!!

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