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

时间:2016-03-29 10:41:30

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

我正在使用带有ASP.NET核心的ASP.NET身份,我有:

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?}"); })

所以我想我正在使用默认订单......

有谁知道我错过了什么?

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

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

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