I am using ASP.NET Core with ASP.NET Identity and have the following:
User user = await _userManager.FindByEmailAsync(myEmail);
SignInResult result = await _signInManager.PasswordSignInAsync(user, myPassword, true, false);
I get a user but when I try to sign in the user I get the error:
[Error] An unhandled exception has occurred while executing the request
System.InvalidOperationException: No authentication handler is configured to handle the scheme: Microsoft.AspNet.Identity.Application
On web project Startup file I have:
public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory) {
// Other configuration code lines
applicationBuilder.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
applicationBuilder.UseIdentity();
} // Configure
public void ConfigureServices(IServiceCollection services) {
// Other configuration code lines
services
.AddIdentity<User, Role>()
.AddEntityFrameworkStores<Context, Int32>()
.AddDefaultTokenProviders();
}
I have no idea what is wrong. I tried to change the configuration and I always get the same error ...
Any idea?
applicationBuilder.UseIdentity();
is what should configure the cookie middleware, make sure that line is called before calling
applicationBuilder.UseMvc()
authentication must be configured before mvc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With