2
我在ASP.NET MVC6應用程序中使用cookie身份驗證。我的配置如下:在dnx restart上丟失驗證
app.UseCookieAuthentication(options =>
{
options.CookieName = "ow.2a";
options.ReturnUrlParameter = "r";
options.AuthenticationScheme = "TwoFactor";
options.ExpireTimeSpan = TimeSpan.FromHours(4.0);
options.SlidingExpiration = true;
options.AccessDeniedPath = new PathString("/login");
options.LoginPath = new PathString("/login");
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
});
這是我的登錄代碼:
await HttpContext.Authentication.SignInAsync("TwoFactor",
new ClaimsPrincipal(new ClaimsIdentity(new[]
{ new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()) }, "Password")),
new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTime.UtcNow.AddHours(4.0) });
我注意到,每一次在一段時間(大約15分鐘),我發現我得到記錄關閉。我已按照these instructions在IIS上託管我的應用程序。這個問題似乎與dnx進程重啓有關。我可以理解,在一段時間不活動後關閉此過程,但不知道爲什麼認證cookie會失效。想法?
這就是它..我沒有任何應用程序/用戶特定的密鑰,所以我不認爲我需要配置數據保護.. –
這就是爲什麼那一步在那裏:)我會提交一個更改使其更清晰。 – blowdart