Introduction:
Here I will explain how to set session timeout in web.config,IIS and in application using asp.net
manually.
Description:
By default our websites session timeout is 20 mins after that session
will gets expire suppose if we want to set our custom timeout in our
applications we can set it in different ways (web.config, global.asax and in
IIS)
Check below methods to set session timeout in web.config,
global.asax and in iis
In Web.config file we can set session timeout like as shown below
<configuration>
<system.web>
<sessionState mode="InProc" cookieless="true"timeout="60"/>
</sessionState>
</system.web>
</configuration>
|
In Global.asax file we can set session timeout
in Session_Start event like this
void Session_Start(object
sender, EventArgs e)
{
// Code that runs when a new
session is started
Session.Timeout = 15;
}
|
In IIS setting you can also set default session
timeout.
1) Open IIS
start-->run type-->inetmgr and press enter.
2)
Right Click on "Default Web Site" go to properties
3) Select Asp.Net tab,
click on "Edit Configuration" Button
4) Select "State
Management tab" in new popup window
In case if you are
using IIS7
Select Default Web Site
>> Click on Session State
Once open Session State
set timeout in under cookie settings section like as shown below
If you set session time out in both web.config and in your iis the
iis session out value overrides web.config session time out
|
If you enjoyed this post, please support the blog below. It's FREE!
Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.
|
Subscribe by RSS
Subscribe by Email
|
|
|
1 comments :
I have been facing this problem since many days, now its solved only becoz of U
Thank U so much