且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在asp.net中的app_Code层(逻辑文件)中使用会话值

更新时间:2021-09-14 01:40:35

你好



你一定是遗失了什么



会话价值将通过



Hi

You must be missing something

Session values will be available through

System.Web.HttpContext.Current.Session["VariableName"]





在获得会话价值之前,你必须设置它。



在尝试获取之前,您没有设置它或会话过期。



Before getting session value you must set it .

Either you are not setting it or your session expires before you trying to get it.


默认情况下,ASP.NET中的会话超时为20分钟。要增加超时或到期,您必须在web.config文件中更改SessionState的超时属性



By default, Session timeouts are 20 minutes in ASP.NET. To increase the timeout or expiry you have to change the timeout attribute for SessionState in the web.config file

<sessionstate timeout="40" />





如果您使用的是表单身份验证,则必须调整此属性:





If you are using Forms authentication, You have to adjust this attribute:

<authentication mode="Forms">
          <forms timeout="40" />
    </authentication>