Just trying to get simple authentication working, but receive exception when trying to login:
Seeded the DB with:
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");
Logging in...
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)
{
}
The following exception is caught:
No authentication handler is configured to handle the scheme: Microsoft.AspNet.Identity.Application
So then my configuration...
Startup.cs ConfigureServices
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
Startup.cs Configure
app.UseIdentity();
What did I miss?
Looks like I missed the fact that app.UseIdentity();
must go before app.UseMvc();