【发布时间】:2016-10-06 10:46:40
【问题描述】:
我在成功注册用户并确认身份验证后收到上述错误。当我尝试调用时发生错误
await _signInManager.SignInAsync(applicationUser, isPersistent);
我首先将服务分配给 IServiceCollection:
services.AddIdentity<ApplicationUser, IdentityRole<int>>(
config => { config.User.RequireUniqueEmail = true;
config.Cookies.ApplicationCookie.LoginPath = "/Account/Login";
config.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents()
{
OnRedirectToLogin = async ctx =>
{
if (ctx.Request.Path.StartsWithSegments("/api") && ctx.Response.StatusCode == 200)
{
ctx.Response.StatusCode = 401;
}
else
{
ctx.Response.Redirect(ctx.RedirectUri);
}
await Task.Yield();
}
};
}).AddEntityFrameworkStores<VisualJobsDbContext, int>()
.AddDefaultTokenProviders();
在我的 Config 启动方法中,我在调用 app.UseMvc 之前调用 app.UseIdentity();
如果我将呼叫更改为:
var myVal = await _signInManager.PasswordSignInAsync(applicationUser, password, true, false);
他们的 myVal 是 'Failed' 我没有收到任何错误抛出
【问题讨论】:
标签: asp.net-core asp.net-identity