aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies set session timeout in web.config IIS

Oct 2, 2010

Here I will explain how to set session timeout in web.config,IIS and in application using manually.


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 

 <sessionState mode="InProc" timeout="60">
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,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

I have been facing this problem since many days, now its solved only becoz of U

Thank U so much

Unknown said...

it is not working using webconfig

Unknown said...

Please reply this coding is not working in webconfig file or global.asax file

Unknown said...

This code need some correction.
However it logically excellent
Correct code is:
<sessionState mode="InProc" cookieless="true" timeout="60">

Note; closing tag and white space at timeout was the problem.

Also code at
void Session_Start(object sender, EventArgs e)
// Code that runs when a new session is started
Session.Timeout = 15;
doesnot works at all.

srujan said...

hi sir, thanks for your beautiful explanation of each topic. I have a small doubt in this topic about of time we are giving. Is it in seconds or in minutes? (in webconfig and in global files)

Suresh Dasari said...

@Thanks Asif... for finding my error

@rajnish... i updated the code...Please check it

Unknown said...

send me the full code fro session time out on logout button click in.simple aspx page and .cs page...
my id is

Unknown said...

Plz give me the sample asax file for start the session and stop the session.

Anonymous said...

Why I am getting session timeout when I do some change in business logic

deva prasad said...


Anonymous said...

how to configure session state..?

Unknown said...

Sir, I want to override the session timeout duration of iis server . How i can override iis session duration by c# code?

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.