1

In my Web.config file, I have been trying to set the session timeout. I used the following code:

<configuration>
   <system.web>
      <sessionState timeout="1"></sessionState>
   </system.web>
</configuration>

When I ran the app, the timeout was still set to the default 20 minutes. Trying to figure out why the settings are not applying. Please help! Thanks!

1 Answer 1

5

Don't be confused between ASP.NET session timeout (which is what you set) and Forms Authentication cookie timeout which is something entirely different and controlled by the <forms> tag:

<authentication mode="Forms">
  <forms
    loginUrl="/login"
    timeout="1" />
</authentication>

ASP.NET session uses cookies to track users (it has nothing to do with authentication) and associate their unique id with a hashtable stored on the server. Forms authentication on the other hand is a means of tracking authenticated users in ASP.NET. It uses cookies but it is a different cookie than the ASP.NET session.

Sign up to request clarification or add additional context in comments.

4 Comments

I already have this kind of code implemented, what I am working on is after about 20 min, all the buttons on the page stop working and the app is essentially broken until you refresh the page. So I want to increase the timeout.
How are those buttons implemented? Are they relying on forms authentication or ASP.NET session?
They have data-binds on them and the click events are bound to functions on JavaScript view model object.
So you are using AJAX? And you are invoking controller actions which require authentication? How are those actions implemented? Do they use ASP.NET session? I guess that once the forms authentication timeout expires they redirect to the LogOn page and break your AJAX calls. Read the following article for possible ways of detecting this condition: haacked.com/archive/2011/10/04/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.