7
사용자를 인증하기 위해 owin 인증 관리자를 사용하려고하지만 User.Identity.IsAuthenticated는 여전히 false입니다.Owin Authentication.SignIn이 작동하지 않음
Startup.cs
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
Startup.Auth.cs
public partial class Startup
{
public static Func<UserManager<ApplicationUser>> UserManagerFactory { get; set; }
public Startup()
{
UserManagerFactory =() =>
{
var userManager = new UserManager<ApplicationUser>(new CustomUserStore());
return userManager;
};
}
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
LogoutPath = new PathString("/Account/LogOff"),
ExpireTimeSpan = TimeSpan.FromDays(7)
});
}
}
인증 활동의 일부 :
private async Task SignInAsync(ApplicationUser user, bool isPersistent)
{
var authManager = return HttpContext.GetOwinContext().Authentication;
authManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
var identity = await userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
authManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, identity);
}
ID는 성공적으로 만들어 지지만 SignIn 메서드는 사용자로 로그인하지 않습니다. 뭐가 문제 야?
브라우저가 쿠키를 보냅니 까? 그것은 브라우저에 의해 보존됩니까? – trailmax
@trailmax, 아니요, 쿠키가 브라우저로 전송되지 않았습니다. – Neshta