Asp.net MVC Session ends

Asked

Viewed 1,145 times

3

I have an app ASP.NET MVC 4.0 on a server of Kinghost. In my web.config I’ll tell you what:

<sessionState timeout="1000"></sessionState>  
   <authentication mode="Forms">     
       <forms loginUrl="~/Login" timeout="1000" >
   </forms>
</authentication>

In my login controller:

FormsAuthentication.SetAuthCookie( agent.IDAgente.ToString() , false );

Obs: I am not using Membership Provider

What happens:

Even if configuring the timeout for 1000 (almost a day) after 2 minutes of browsing the session drops. What I use to fetch session data is: HttpContext.Current.Session["variavel"].

What could be causing this?

  • Just one question, do you lose session during the test? Make code modifications?

3 answers

0

Put in your timeout="30" which is 30 minutes, by Microsoft MSDN Website Reference says that: "Property Timeout cannot be set to a value greater than 525,600 minutes (1 year). Default value is 20 minutes.", must be the problem, because, you exceeded the maximum allowed that is 525,600. Just remembering that the value is in minutes.

Reference

  • Sorry I didn’t understand. I put one day (1000) and you’re saying I exceeded the one-year limit. (525600)

  • @Ozory I put 525,600 quinhentos e vinte e cinco e seiscentos

  • Sorry now I understand...

  • user6026 thanks for the tip, but still doesn’t work. I don’t know what else can be.... : /

  • The correct is 525,600 minutes even, which divided by 60 and then by 24 results in 365 days. 525 minutes is not equivalent to one year

0

Check that the Kinghost server does not have any timeout settings.

That of session time may be related to the server and iis, I once had a site on a shared server where sessions blew up in 5 minutes or less, they had x memory available for each site, when it reached that memory iis itself makes a "Recycle" to the pool that the site is associated with and clears all sessions, then I switched the site for a vps and never again had problem.

You have to see if your site isn’t consuming too much memory as well, because in vps I had a site that was consuming a lot memory(did not test some data that came with get and error in script, spending a lot of memory on the server), and after handling the problem became good.

source:http://forum.imasters.com.br/topic/460500-sessiontimeout-nao-funciona/

0


It’s been two years, I’ve gone a long way to find out what use Asp.net mvc4 (Asp.net 4.5) but the Kinghost server is configured to run with Asp.net 3.5.

In short, . net 4.5 consumes twice as much memory as. net 3.5. If the server is not configured to give this memory to the application, it simply "knocks down" the active sessions to free up memory.

This is something that even the Kinghost team could not answer me, since they are experts in PHP but want to offer . net.

Too bad. But thank you @user6026 and @Spectron

Browser other questions tagged

You are not signed in. Login or sign up in order to post.