4

I want to set the session timeout in code so it can come from a configurable value.

Can I just do this in global.asax?

Session.Timeout = value;

1
  • If you want the session timeout to be configurable, is there a reason why you can't use the sessionState element of web.config? Commented Feb 2, 2011 at 11:28

2 Answers 2

6

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 .

Sign up to request clarification or add additional context in comments.

Comments

4

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.