简体   繁体   中英

ASP.NET Forms authentication timeout expires too soon

I have read a lot of examples but I dont know why my code doesn't work. This is a part of my web.config code in my ASP.NET project:

  <system.web>
      <authentication mode="Forms">
        <forms loginUrl="Panel/Login" timeout="525600" slidingExpiration="true" />
      </authentication>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" maxRequestLength="1048576" />
  </system.web>

The problem is that when I login, after a few minutes of inactivity when I try to request something I'm navigated to the Login page. This happens even if I set persistent cookie in my Login page!

I've tried to increase and decrease timeout attribute.

I've tried slidingExpiration attribute.

I've tried cookieless attribute.

None of them works!

I use this code in Login page:

FormsAuthentication.SetAuthCookie(Username.Text, Remember_Me.Checked);

Thanx in advance.

You can try to add machineKey to your code :

<machineKey validationKey=”AutoGenerate”

You can see more detailed information here :

http://blog.falafel.com/asp-net-forms-authentication-times-out-on-a-shared-host/

Or this maybe in help :

Asp.net forms authentication cookie not honoring timeout with IIS7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM