简体   繁体   English

空Session对象会记住sessionID吗?

[英]Empty Session object remembers the sessionID?

Im certain that Session id keeps changing if no value is stored in it. 我确定如果没有存储任何值,Session ID会不断变化。

在此输入图像描述

but seems that 2010 have an exception : here is the demo vid 但似乎2010年有一个例外: 这是演示视频

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) 奇怪,但在回发后/刷新/ ctrl + f5:我得到相同的数字......但它应该是那样....(因为我没有存储任何东西)

在此输入图像描述

what am i missing? 我错过了什么?

ps Session.Count =0..... ps Session.Count = 0 .....

edit 编辑

ive just run the same code in vs2005 and a new session id is each time !!!! 我只是在vs2005中运行相同的代码,每次都有一个新的会话ID!

在此输入图像描述

在此输入图像描述

在此输入图像描述

It should be like that. 它应该是那样的。

Session is a special ASP.NET runtime object that exists for all requests/responses during the determined time. Session是一个特殊的ASP.NET运行时对象,在确定的时间内存在于所有请求/响应中。 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 ASP.NET中的会话超时

You also able to control where the session is persisted between the request. 您还可以控制请求之间持久会话的位置。

http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx

In Memory state management is simplies one, it just keeps Session object in RAM. 在内存状态管理简化一个,它只是将Session对象保存在RAM中。 So in case of app-pool is recycled all data is gone. 因此,如果app-pool被回收,所有数据都将消失。 More production-ready scenarios include SQL state management. 更多生产就绪方案包括SQL状态管理。

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. 编辑:我只是假设,然后你在VS2005上运行,你运行旧版本的ASP.NET Web开发服务器(卡西尼),确实我的工作方式是每个新请求都有Session,如果还没有存储在Session中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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