没有配置身份验证处理程序来处理该方案:Microsoft.AspNet.Identity.Application

Mig*_*ura 4 asp.net-core-mvc asp.net-core

我使用ASP.NET Core与ASP.NET身份,并具有以下内容:

User user = await _userManager.FindByEmailAsync(myEmail);

SignInResult result = await _signInManager.PasswordSignInAsync(user, myPassword, true, false);
Run Code Online (Sandbox Code Playgroud)

我得到一个用户,但当我尝试登录用户时,我得到错误:

[Error] An unhandled exception has occurred while executing the request
Run Code Online (Sandbox Code Playgroud)

System.InvalidOperationException:没有配置身份验证处理程序来处理该方案:Microsoft.AspNet.Identity.Application

在Web项目启动文件我有:

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();
}
Run Code Online (Sandbox Code Playgroud)

我不知道出了什么问题.我试图改变配置,我总是得到同样的错误......

任何的想法?

Joe*_*tte 7

applicationBuilder.UseIdentity(); 
Run Code Online (Sandbox Code Playgroud)

应该配置cookie中间件,确保在调用之前调用该行

applicationBuilder.UseMvc()
Run Code Online (Sandbox Code Playgroud)

必须在mvc之前配置身份验证