Redone
Redone

Reputation: 1303

Asp.net MVC 3 session not expiring on expected time

Session in asp.net is not expiring on expected time. Below is my part of web.config file for session configuration. Here i want to expire my session in 2 minutes and redirect the user to login page for test purpose. Here session expires about 6 to 7 minutes later.

<system.web>
    <sessionState mode="InProc" timeout="2" />
    <authentication mode="Forms">
          <forms loginUrl="/Home/Login" timeout="2" />
    </authentication>
</system.web>

Thanks.

Upvotes: 0

Views: 1524

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

Make sure you have disabled sliding expiration:

<system.web>
    <sessionState mode="InProc" timeout="2" />
    <authentication mode="Forms">
          <forms loginUrl="/Home/Login" timeout="2" slidingExpiration="false" />
    </authentication>
</system.web>

Now no matter whether you are sending requests to the application during the period, the forms authentication cookie won't be renewed.

Upvotes: 4

Related Questions