Reputation: 25
I am new to .net technology, i am confused in the concept of session , simply i want to know when session will be expired?
1) is it timeout of session
(or)
2) user being idle.
please clarify my doubt anyone.
Upvotes: 1
Views: 2213
Reputation: 523
There are a lot of reasons for session loss. To name a few,
- Application Pool is recycled. - We will know this looking at the system logs
- IIS/worker process is restarted. - System logs will tell this as well
- Application Domain is restarted. - We need to monitor for application restarts for the ASP.NET counter in
perfmon
to check this. Few reasons for application restarts include
- Bin folder of the application is touched by some application
- Web.config or the machine.config is touched
- Global.asax file is touched
- Antivirus is running
- Something in the code is causing session loss, it can be anything. You will need to look into the code to have a fix on this.
- And many more...
source: MSDN Blog
Upvotes: 1
Reputation: 93434
Session is something you should avoid if at all possible. It doesn't scale well, and is unreliable. If you do use Session, it should be short lived because you cannot guarantee how long a session will stay active for InProc sessions.
In any event, Sessions can be either a timeout, or idle depending on your settings. If you enable sliding timeout, it effectively becomes an idle timeout. If you do not enable sliding timeout, then it's a flat time based timeout.
However, again, just because the timeout may be 20 minutes there is no guarantee that it will be available for 20 minutes.
Upvotes: 0
Reputation: 327
Session in asp.net will expire after the timeout, by default the timeout is 20 minutes [msdn reference].
This timeout is sliding timeout that means if user shows any activity within these 20 minutes the countdown again starts from 20 minutes. So in order for expiration of session, user should sit idle for 20 minutes.
You can change this timeout in your Web.config's tag as shown below.
<sessionState mode="InProc" cookieless="false" regenerateExpiredSessionId="true" timeout="35">
<providers>...</providers>
</sessionState>
Upvotes: 0