Sami
Sami

Reputation: 3976

Session timeout issue in ASP.NET

I have read some issues related to session time out and i have changed the settings but no avail.

This is entry of session in web.config. i want to expire the session after 5 hours.

<sessionState mode="InProc" timeout="300" />

On Login page i am adding user name in session

Session.Add("Authenticated", UserName);

and my each page is inherited with BasePage and in base class i have this check for each page.

if (Session["Authenticated"] == null)
{
   Response.Redirect("../userlogin.aspx");
}

but session expires before one hour.

I want to confirm that during this there is no change in web.config, Bin folder files etc.

Upvotes: 1

Views: 4054

Answers (2)

Alex Aza
Alex Aza

Reputation: 78447

Take a look at this ASP.NET Session Timeouts.

Besides IIS Idle timeout there is Forms authentication timeout, which is 30 min by default. So you will be redirected to the login page before the session actually expired.

<system.web>
    <authentication mode="Forms">
         <forms timeout="300"/>
    </authentication>

    <sessionState timeout="300"  />
</system.web>

Upvotes: 2

Kangkan
Kangkan

Reputation: 15571

If you are hosting it on IIS6 (Win2K3) then go to the settings in the Application Pool in which your application runs. You need to set it there as well.

Upvotes: 0

Related Questions