2014-02-28 2 views
0

첫 번째 .net MVC5 프로젝트를 설정하고 로그인해도 작동하지만 로그 아웃하지 않으면 밤새 아이덴티티가 유지됩니다. 나는 isPersistent 플래그를 false로 설정하면이 문제를 방지 할 수 있다고 생각했지만, 그렇지 않은 경우이 문제를 해결하는 방법을 알려주는 설명서가 없습니다. 여기 .net MVC ID는 세션간에 지속됩니다.

private async Task SignInAsync(SdIdentityUser user, bool isPersistent) 
{ 
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); 
    var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); 
    Session["user"] = user; 
    AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity); 
} 

로그인 내 비동기 방식입니다 그리고 여기 메서드 호출입니다

await SignInAsync(user, isPersistent: false); 

그리고 여기가

app.UseCookieAuthentication(new CookieAuthenticationOptions 
    { 
     AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
     LoginPath = new PathString("/Account/Login") 
    }); 
    // Use a cookie to temporarily store information about a user logging in with a third party login provider 
    app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 

답변

1

나는 내 Startup.Auth 구성입니다 가능하면이 질문을 삭제합니다. 그 대답은 false로 올바르게 설정되면 영구적 인 것으로 판명되었습니다. 내 코드에는 플래그가 true로 설정되는 결함이있었습니다.

관련 문제