我在网站上使用MVC5 OWIN身份验证时遇到登录持久性问题。用户将在5分钟后自动退出,但他们已经检查过我的选项。
在localhost上运行我的网站时,一切都运行正常,当我将网站发布到并行主机窗口时,问题就出现了。 我的登录代码:
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent , ExpiresUtc = DateTime.Now.AddDays(14) }, identity);
My Startup.Auth.cs
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/dang-nhap"),
ExpireTimeSpan = new System.TimeSpan(14,0,0)
});
我在webconfig中的system.web部分,我已经包含了machineKey Tag
<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,虽然过期时间已经设置为记录后的14天,但用户在5分钟后自动退出,因为缺乏声誉而无法发布图片。
答案 0 :(得分:1)