Im certain that Session id keeps changing if no value is stored in it.
but seems that 2010 have an exception : here is the demo vid
new page ( empty project) :
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Session.SessionID);
}
strange but after postback / refresh / ctrl+f5 : i get the same number...but it should'nt be like that....(since i didnt store nothing)
what am i missing?
p.s. Session.Count =0.....
ive just run the same code in vs2005 and a new session id is each time !!!!
It should be like that.
Session is a special ASP.NET runtime object that exists for all requests/responses during the determined time. It's by design that it remains the same, doesn't matter it's page load or post back.
The session terminates then it reach it's timeout period. You might control what exact timeout you want to keep you session alive:
Session timeout in ASP.NET
You also able to control where the session is persisted between the request.
http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx
In Memory state management is simplies one, it just keeps Session object in RAM. So in case of app-pool is recycled all data is gone. More production-ready scenarios include SQL state management.
EDIT: I just assume, that then you running on VS2005, you run on old version of ASP.NET Web Development server (Cassini) that indeed my work in the way to have Session with each new request, if nothing is stored in Session yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With