开发者

ASP.NET Can you set session timeout value in C#

开发者 https://www.devze.com 2023-02-08 06:23 出处:网络
I want to set the session timeout in code so it can come from a configurab开发者_运维技巧le value.

I want to set the session timeout in code so it can come from a configurab开发者_运维技巧le value.

Can I just do this in global.asax?

Session.Timeout = value;


to change session timeout write this code in your web.config file

or you can also set this in global.asax file as

Session.Timeout = 60 ; // in Session.Start() event

it will increase your session expire time .


From the MSDN page describing the TimeOut property:

The Timeout property can be set in the Web.config file for an application using the timeout attribute of the sessionState configuration element, or you can set the Timeout property value directly using application code.

So yes, you can assign a value to this property and the Global.asax is a good place to do this.

0

精彩评论

暂无评论...
验证码 换一张
取 消