Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty Session object remembers the sessionID?

Im certain that Session id keeps changing if no value is stored in it.

enter image description here

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)

enter image description here

what am i missing?

p.s. Session.Count =0.....

edit

ive just run the same code in vs2005 and a new session id is each time !!!!

enter image description here

enter image description here

enter image description here

like image 393
Royi Namir Avatar asked Nov 04 '22 01:11

Royi Namir


1 Answers

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.

like image 152
Alexander Beletsky Avatar answered Nov 09 '22 08:11

Alexander Beletsky