Reputation:
I am implementing my own session provider, and would like to know if the default of 20 minutes is set in the session provider automatically? Is this value provided whether or not an entry is in the configuration file?
If not should my session provider is supposed to get it from another location?
Upvotes: 12
Views: 27580
Reputation: 3497
Try using:
System.Int64 timeout = System.Web.HttpContext.Current.Session.Timeout; // The time-out period, in minutes
Upvotes: 12
Reputation:
I couldn't find the value in a global configuration file, but it's defined somewhere.
Using the following code you can get the session timeout value whether or not it is defined in your local web.config.
Configuration conf = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
SessionStateSection section = (SessionStateSection) conf.GetSection("system.web/sessionState");
int timeout = (int) section.Timeout.TotalMinutes;
Upvotes: 18
Reputation: 510
In Global.asax, you can set
Session.TimeOut
in Session_Start or set it in other place in the code.
Upvotes: 1
Reputation: 1347
http://msdn.microsoft.com/en-us/library/aa478952.aspx
According to the article I've linked above, if the Timeout value is not set anywhere, a default of 20 minutes will be used. This seems to be the case for both custom providers and built-in.
Upvotes: 0