I am using MVC5. at every 15 minute or before it session is expired below is the code that i have added in web.config file
authentication mode="None" sessionState mode="InProc" timeout="20" Please Help me. Thank you
InProc session storage is in-memory and tied to the process. In other words, it's volatile: both because the memory can be reclaimed and the process can be killed. In particular the App Pool is set to recycle periodically by default and can also crash, or IIS or the server itself could be restarted. All of these will destroy any active sessions.
InProc is really only viable in development, to save you from having to set up an actual session store, just to play with some code. In production, you should always be using something else, like SQL Server or Redis. Even in development, it's important to realize that, again, since it's tied to the process, doing something like stopping and restarting debugging will kill the IIS Express process and thus your session state.
If you're hosting your website in IIS and you've not made any request to your website for 15 minutes, then it's likely the app pool has been recycled. It means that any data that was stored in memory (like the session state as you specified mode="InProc") has been lost and a new thread was created when accessing the website after 15 minutes. You would easily notice if this is the case as the app pool start up time can take 10 to 30 seconds - which explains why the first request take so long to render and subsequent requests are much faster.
If this is happening on your local machine, any re-compilation of your code would have the same effect.
Another possibility is that you are behind a load balancer and that the second request doesn't go to the same physical server which served the first request. (obviously, the second server has no knowledge of what's in memory on the first server)
For those reasons, it's best to avoid mode="InProc". You wouldn't want to use mode="InProc" in production, and it's better to stick with the same settings in Development, so you can see any issues early.
<authentication>
and its child<forms>
tag: https://stackoverflow.com/a/17741890/1361831 – Tiramonium