Click here to Skip to main content
14,209,828 members
Click here to Skip to main content
Tip/Trick
Posted 28 Oct 2014

Tagged as

Stats

17.5K views
6 bookmarked

ASP.Net Session Expired Problem

,
Rate this:
3.00 (6 votes)
Please Sign up or sign in to vote.
3.00 (6 votes)
28 Oct 2014     CPOL    
Some thoughts about session expired problem in ASP.Net

Introduction

Most of the asp.net application using session, especially data driven applications. Mostly these kind of application using “Inproc” mode of session. During development the developer does not face any kind of problem with the session. When deploy the application the problem arise one by one. In this post I just want to share some thoughts and highlight some points to look into during this issue encountered.

Shared Hosting:

                  Long back ago, I have developed one small application and bought hosting “shared” hosting plan. In this point the pain started, what happened is session has been shared between the user and session has been expired soon. After some chat with my provider I came to know that they also use web-farm (also using Load balancer) plus shared hosting. In order to maintain the session of a user, the machine key must be same between the server. But that kind of provisions not given by that host provider. However, the session time out set is 20 minutes. If the Load balancer problem fixed also your user will be push out from application 20 minutes. My point over here is, if you have an application, tightly coupled with Session means, you should  consider this.

In Web.Config File:

Session State Node:
                    As a first step, check that web.config contains a valid entry on the “sessionState”. The “timeout” attribute denotes the idle time in minutes before a session is abandoned. By default, the time is 20 minutes. You can find more info about the “sessionState” in the below MSDN url:

http://msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.71).aspx

Form Authentication:
                       Some times form authentication will create some tricks. Scott Hanselman gives a detailed overview on this topic.
http://www.hanselman.com/blog/WeirdTimeoutsWithCustomASPNETFormsAuthentication.aspx

IIS Configuration:

You should also focus on the below IIS configuration elements, since they play a vital role too.

In IIS, select the “Application Pools” node, and select the application pool you have used and then select “Advanced Settings”.

In the “Advanced Settings” popup, under the “Process Model” set the property “Idle Time-out (minutes)”.

There is another property called, “Regular Time Interval” under the “Recycling” node. This property is used to specify the period of time after that application pool will recycle.

Anti-Virus Softwares:

Apart from these, some times if anti-virus software will do the trick. During the scanning of the web.config file it will update the web.config file's date time (not the content). Which can be notified by the ASP.Net runtime, in turn it will recycle the app pool. To avoid this type of scenario, it is always best to keep away the web.config file from anti-virus program scanning.

Let me know your thoughts as comments :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Francis S Michael
Software Developer (Senior)
India India
Hi All, I am Francis from India. Working as a Senior Software Engineer. I have 6+ Years of experience in ASP.Net and C#/VB.Net. Also founder of ASPDotNetChamp, where i blog my day to day ASP.Net Experiences, Problems and Interview Questions.

Comments and Discussions

 
QuestionMy session is also expiring Pin
sushma26073-Mar-15 22:35
membersushma26073-Mar-15 22:35 
AnswerRe: My session is also expiring Pin
Francis S Michael3-Mar-15 23:53
professionalFrancis S Michael3-Mar-15 23:53 
GeneralMy vote of 1 Pin
jackmos3-Nov-14 7:03
professionaljackmos3-Nov-14 7:03 
GeneralRe: My vote of 1 Pin
Francis S Michael9-Nov-14 9:24
professionalFrancis S Michael9-Nov-14 9:24 
GeneralMy vote of 1 Pin
Jeevan Malepati28-Oct-14 20:49
memberJeevan Malepati28-Oct-14 20:49 
GeneralRe: My vote of 1 Pin
Francis S Michael9-Nov-14 9:21
professionalFrancis S Michael9-Nov-14 9:21 
QuestionPicture does not Show Pin
Laiju k28-Oct-14 18:28
professionalLaiju k28-Oct-14 18:28 
AnswerRe: Picture does not Show Pin
Francis S Michael9-Nov-14 9:20
professionalFrancis S Michael9-Nov-14 9:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190617.3 | Last Updated 29 Oct 2014
Article Copyright 2014 by Francis S Michael
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid