Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Session State not working in Web.config as well as Global.asax

I have Admin Page wherein I use to do some update work for my site. The problem is the session will expire within a minute or 30 seconds and will logout the user. I have set the Session in Web.Config of the root folder as well as in the Web.Config inside the Admin folder but still the session gets expired soon. I have set it to 60 minutes but it only lasts for 30 seconds or within a minute. Here is my web.config content of root folder

<sessionState timeout="60" mode="InProc" 
      cookieless="false"></sessionState>


    <customErrors mode="Off">
    </customErrors>
    <trace enabled="true" />
    <authentication mode="Forms">
               <forms
    protection="All"
    timeout="120"
    domain="www.marpallichande.in"
    slidingExpiration="true"
    name="auth_cookie" />  

    </authentication>

and this is my setting of web.cofing file inside the Admin folder

<sessionState timeout="60" mode="InProc"
      cookieless="false"></sessionState>

and this is my setting in Global.asax file under Session_Start method

Session.Timeout=60;

I am not getting how the session is getting expired so soon or is there any other reason for been getting logged out other than session.

like image 771
Guruprasad J Rao Avatar asked Jan 13 '14 17:01

Guruprasad J Rao


People also ask

How do I enable session state in IIS?

To enable in-process session state by using the UIOpen IIS Manager and navigate to the level you want to manage. In Features View, double-click Session State. On the Session State page, in the Session State Mode Settings area, click In process.

What is session state in Web config?

The SessionStateSection class refers to the element in the Machine. config or Web. config configuration file identified by the sessionState tag.

What is sessionState mode InProc?

InProc session mode indicates that session state is stored locally. This means that with InProc session state mode is stored as life objects in the AppDomain of the Web application. This is why the session state is lost when Aspnet_wp.exe (or W3wp.exe, for applications that run on IIS) or the AppDomain restarts.


1 Answers

sessionState timeout value is in minutes. I would start by removing Session.TimeOut (and any other timeout values except sessionState timeout, leave it as it is and give it a try. Also, not sure why you have two config files? Do they have same settings?

I have a similar setup but just one config file with

<sessionState mode="InProc" cookieless="false" timeout="10" /> 

setting it to 10 minutes.

like image 79
skolte Avatar answered Oct 13 '22 21:10

skolte