Last post Jun 24, 2007 11:06 PM by Rex Lin - MSFT
Jun 22, 2007 09:11 AM|EricEqt|LINK
I don't understand why the Asp Net Session ID is different between the main page and the page call by Sys.Net.WebRequest object.
I have in my cookie the variable Asp.Net_SessionId right on the client script, but on the server with the call by Sys.Net.WebRequest object, i have a anothe value of session id and then i don't have the same session that the main page.
I don't have any HttpModule to catch Session or other.
Jun 24, 2007 11:06 PM|Rex Lin - MSFT|LINK
The HttpWebRequest class has a CookieContainer property that is null by default. Create a new CookieContainer and assign it to the request. When you get the response you can call CookieContainer.GetCookies( requestUri ) and look through the cookies. The
ASP session cookis is called "ASP _SessionId", the next time a request is made create a cookie container for it and add the session cookie and then ASP will recognize the session
the session (on the serverside) is associated
with client via a cookie variable named "ASP.NET_SessionId". If we want to
mantain the session outside , not via asp.net page request, we need to
manually retrieve the cookie variable from cookie collection and repost it
next time so as to maintain the association. In addition, as the other
customer has mentioned, if
the client doesn't support cookie, the ASP.NET serverside also provide a
cookie less session implmentation , which will put the session id as
encryped value in the url, thus, we can't use cookie variable to retrieve
the sessoinid. For detailed info on the ASP.NET session implemention, you
can view the following reference in MSDN:
#Underpinnings of the Session State Implementation in ASP.NET
Also, here is a tech ariticle discussing the cookie in ASP.NET
#basics of cookies in asp.net
Hope they're also helpful to you.