簡體   English   中英

ASP.NET Forms身份驗證超時過期太早

[英]ASP.NET Forms authentication timeout expires too soon

我已經閱讀了很多示例,但是我不知道為什么我的代碼不起作用。 這是我的ASP.NET項目中web.config代碼的一部分:

  <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>

問題是,當我登錄后,在閑置幾分鍾后,當我嘗試請求某些內容時,我導航到“登錄”頁面。 即使我在“登錄”頁面中設置了持久性Cookie,也會發生這種情況!

我試圖增加和減少timeout屬性。

我試過了slidingExpiration屬性。

我嘗試了cookieless屬性。

它們都不起作用!

我在登錄頁面中使用以下代碼:

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

提前感謝。

您可以嘗試將machineKey添加到您的代碼中:

<machineKey validationKey=”AutoGenerate”

您可以在此處查看更多詳細信息:

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

或者這可能在幫助中:

ASP.NET表單身份驗證Cookie不支持IIS7超時

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM