2015-07-01 20 views
0

我在我的網站上遇到了使用MVC5 OWIN身份驗證的登錄持久性問題。用戶將在5分鐘後自動退出,儘管他們已經檢查過記住我的選項。在本地主機上運行我的網站時,MVC5 OWIN身份驗證持久化在生產中不起作用

一切工作的完美,當發佈我的網站並行主機窗口,問題發生了。 我的登錄代碼:

AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent , ExpiresUtc = DateTime.Now.AddDays(14) }, identity); 

我Startup.Auth.cs

在Webconfig
app.UseCookieAuthentication(new CookieAuthenticationOptions 
{ 
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
    LoginPath = new PathString("/dang-nhap"), 
    ExpireTimeSpan = new System.TimeSpan(14,0,0) 
}); 

我的System.Web節,我已經包括的machineKey標籤

<system.web> 
<customErrors mode="Off"/> 
<machineKey /> 
<authentication mode="None" /> 
<compilation debug="true" targetFramework="4.5" /> 
<httpRuntime targetFramework="4.5" /> 
<pages> 
    <namespaces> 
    <add namespace="MvcPaging" /> 
    </namespaces> 
</pages> 

我的網站在我的電腦上發佈的cookie,雖然過期時間已經設置爲logg後的14天用戶在5分鐘後自動退出,由於缺乏聲譽,我無法發佈圖片。

回答

1

「記住我」的價值應該去上下文的ispersistant屬性。票。 AuthorizationCodeExpireTimeSpan是您需要設置的任何一天到期的財產。此Propery的默認過期時間爲5分鐘,因此您的應用在5分鐘內超時。