Reputation: 1
I'm having an issue with login persistency using MVC5 OWIN authentication on my website. User will sign out automatically after 5 minutes, although they've checked remember me option.
Everything work perfectly when running my website on localhost, When publishing my website to parallel host window, the issue happened. My Login Code:
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)
});
My system.web section in Webconfig, I've include 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>
The cookie that my website issue on my computer, although the expire time has been set to 14 days after logging, the user is automatically sign out after 5 minutes, I can't post image because of lacking of reputation.
Upvotes: 0
Views: 810
Reputation: 422
"Remember Me" value should go to ispersistant property of the context.Ticket. AuthorizationCodeExpireTimeSpan is the property you need to set to have an expiry of whatever day you want. The default expiry of this propery is 5 minutes and hence your app is timing out in 5 min.
Upvotes: 1