由于 Microsoft.AspNet.Identity.Application 错误无法登录
Unable to sign-in because of Microsoft.AspNet.Identity.Application error
只是试图让简单的身份验证工作,但在尝试登录时收到异常:
为数据库播种:
user = new ApplicationUser
{
FirstName = "John",
LastName = "Smith",
UserName = "jsmith",
Email = "jsmith@gmail.com",
EmailConfirmed = true,
LockoutEnabled = false
};
var result = await _userManager.CreateAsync(user, "P@ssW4rd");
正在登录...
var b = await _securityManager.FindByEmailAsync(model.Username);
try
{
var result = await _loginManager.PasswordSignInAsync(b.UserName,
model.Password, false, lockoutOnFailure: false);
if (result.Succeeded)
{
return RedirectToReturnUrl(returnUrl);
}
}
catch (Exception e)
{
}
捕获到以下异常:
No authentication handler is configured to handle the scheme:
Microsoft.AspNet.Identity.Application
那么我的配置...
Startup.cs ConfigureServices
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
Startup.cs Configure
app.UseIdentity();
我错过了什么?
看来我错过了 app.UseIdentity();
必须在 app.UseMvc();
之前的事实
只是试图让简单的身份验证工作,但在尝试登录时收到异常:
为数据库播种:
user = new ApplicationUser
{
FirstName = "John",
LastName = "Smith",
UserName = "jsmith",
Email = "jsmith@gmail.com",
EmailConfirmed = true,
LockoutEnabled = false
};
var result = await _userManager.CreateAsync(user, "P@ssW4rd");
正在登录...
var b = await _securityManager.FindByEmailAsync(model.Username);
try
{
var result = await _loginManager.PasswordSignInAsync(b.UserName,
model.Password, false, lockoutOnFailure: false);
if (result.Succeeded)
{
return RedirectToReturnUrl(returnUrl);
}
}
catch (Exception e)
{
}
捕获到以下异常:
No authentication handler is configured to handle the scheme: Microsoft.AspNet.Identity.Application
那么我的配置...
Startup.cs ConfigureServices
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
Startup.cs Configure
app.UseIdentity();
我错过了什么?
看来我错过了 app.UseIdentity();
必须在 app.UseMvc();