ASP.NET Authentication sliding expiry time on custom ticket

前端 未结 1 594
醉梦人生
醉梦人生 2020-12-30 08:14

I am creating my own authentication ticket using the following code:

string formsCookieStr = string.Empty;
FormsAuthenticationTicket ticket = new FormsAuthen         


        
相关标签:
1条回答
  • 2020-12-30 08:35

    That's configured in the forms section of web.config. The way sliding expiration works is that on each request the ASP.NET engine rewrites the authentication cookie by incrementing the timeout:

    <authentication mode="Forms">
      <forms 
          loginUrl="~/Account/LogOn" 
          timeout="2880" 
          slidingExpiration="true" 
      />
    </authentication>
    

    Note however that enabling sliding expiration is one of the things considered as bad practice in the ASP.NET Security Practices.

    0 讨论(0)
提交回复
热议问题