【问题标题】:No authentication handler is configured to handle the scheme Microsoft.AspNet.Identity.Application没有配置身份验证处理程序来处理方案 Microsoft.AspNet.Identity.Application
【发布时间】:2016-03-29 10:41:29
【问题描述】:

我正在使用带有 ASP.NET 核心的 ASP.NET Identity,并且我有:

services.AddIdentity<User, Role>();

当我登录时,这工作正常。但后来我尝试了这个设置:

services
  .AddIdentity<User, Role>(x => {
    x.Cookies = new IdentityCookieOptions {             
      ApplicationCookie = new CookieAuthenticationOptions {
        AccessDeniedPath = new PathString("/signin"),
        AuthenticationScheme = "cookies",
        AutomaticAuthenticate = true,
        AutomaticChallenge = true,
        CookieName = "_ath",
        LoginPath = new PathString("/signin"),
        LogoutPath = new PathString("/signout")
      }
    };
    })
    .AddEntityFrameworkStores<Context, Int32>()
    .AddDefaultTokenProviders();          

这样我得到以下错误:

No authentication handler is configured to handle the scheme: 
Microsoft.AspNet.Identity.Application    

请注意,我有 AuthenticationScheme = "cookies"AutomaticAuthenticate = trueAutomaticChallenge = true

我在 Starttup / Configure 方法中也有以下内容:

  applicationBuilder
    .UseIdentity()
    .UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}"); })

所以我想我使用的是默认顺序...

有人知道我错过了什么吗?

【问题讨论】:

    标签: asp.net-core asp.net-core-mvc asp.net-core-1.0 asp.net-identity-3


    【解决方案1】:

    我遇到了完全相同的错误,并通过添加默认令牌提供程序来修复它,如下所示:

    services.AddIdentity<User, IdentityRole>()
                .AddDefaultTokenProviders();
    

    【讨论】:

    • 不幸的是,这对我没有帮助,因为我已经拥有了。我更新了我的问题的代码以反映它...
    【解决方案2】:

    不要直接设置 authenticationScheme,或者如果你这样做了,你需要确保你也更新了 IdentityOptions 中的相应选项以全部匹配。

    错误消息意味着身份可能仍被配置为在某处使用默认值“Microsoft.AspNet.Identity.Application”,并且您将 cookie 中间件更改为不匹配的不同方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      • 1970-01-01
      相关资源
      最近更新 更多