加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-core – 未配置身份验证处理程序来处理该方案:Microsof

发布时间:2020-12-16 06:34:05 所属栏目:asp.Net 来源:网络整理
导读:我使用ASP.NET Core与ASP.NET身份,并具有以下内容: User user = await _userManager.FindByEmailAsync(myEmail);SignInResult result = await _signInManager.PasswordSignInAsync(user,myPassword,true,false); 我得到一个用户,但当我尝试登录用户时,我得
我使用ASP.NET Core与ASP.NET身份,并具有以下内容:

User user = await _userManager.FindByEmailAsync(myEmail);

SignInResult result = await _signInManager.PasswordSignInAsync(user,myPassword,true,false);

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

[Error] An unhandled exception has occurred while executing the request

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();
}

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

任何的想法?

解决方法

applicationBuilder.UseIdentity();

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

applicationBuilder.UseMvc()

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读