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

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

Can I just do this in global.asax?

Session.Timeout = value;

+4
source share
2 answers

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

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

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

this will increase the session expiration time.

+6
source

On the MSDN page that describes the TimeOut property:

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

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

+4
source

Source: https://habr.com/ru/post/1338085/


All Articles