开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜