2017-12-28 12 views
0

MVC5에서 ASP.NET ID를 사용하고 있으며 일정 기간이 지나면 로그인 한 사용자를 만료시키기를 원합니다. 난의 Web.config의 경우 System.Web 섹션을 추가했습니다 :MVC5의 인증 시간 초과

var authenticationManager = HttpContext.GetOwinContext().Authentication; 
authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); 
var identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); 
authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, identity); 

그러나 사용자가 기록되지 않습니다 : 나는 또한 영구 쿠키를 사용하지 않는 로그인 코드를 변경 한

<authentication mode="Forms"> 
    <forms timeout="1" slidingExpiration="false"/> 
</authentication> 

밖으로 나가면, 그들은 영원히 계속 로그인 할 수 있습니다.

답변

0

양식 인증과 ASP.NET ID간에 ​​차이가있는 것 같습니다. Identity를 사용하는 경우 web.config 설정은 아무런 영향을 미치지 않습니다. 정체성에 대한

설정은 App_Start \ Startup.Auth.cs에 있습니다

app.UseCookieAuthentication(new CookieAuthenticationOptions 
    { 
     AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
     LoginPath = new PathString("/"), 
     ExpireTimeSpan = TimeSpan.FromMinutes(24), 
     SlidingExpiration =false 
    }); 
관련 문제