사용자가 웹 사이트에 액세스하고 데이터베이스에 저장된 자격 증명을 입력하면 인증을 만들 때 우리는 인증을 만듭니다.MVC 5에서 OwinContext의 TimeOut을 설정하는 방법
어떻게 타임 아웃을 설정합니까? MVC 5. 사용
내 인증은 다음과 같습니다
// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
ExpireTimeSpan = TimeSpan.FromDays(2)
});
:
var claims = new List<Claim>();
claims.Add(new Claim("UserId", user.UserID.ToString()));
claims.Add(new Claim(ClaimTypes.Name, user.FirstName + " " + user.LastName));
claims.Add(new Claim(ClaimTypes.Email, user.Email));
claims.Add(new Claim(ClaimTypes.NameIdentifier, user.UserID.ToString()));
var id = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
var ctx = Request.GetOwinContext();
var authenticationManager = ctx.Authentication;
authenticationManager.SignIn(id);
수정되었지만 수정이 필요합니다. authenticationManager.SignIn (새 AuthenticationProperties {IsPersistent = true}, id); – DavidJS
다행입니다. 질문에 답변으로 표시하십시오. – Dave
이게 다행스럽게도 나에게 효과가 없나요? –