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

Guruprasad J Rao picture Guruprasad J Rao · Jan 13, 2014 · Viewed 40.5k times · Source

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.

Answer

skolte picture skolte · Jan 13, 2014

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.