简体   繁体   中英

Empty Session object remembers the sessionID?

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?

ps Session.Count =0.....

edit

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM