我正在将 ASP.NET Identity 与 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 = true
AutomaticChallenge = true
我在 Starttup / Configure 方法中也有以下内容:
applicationBuilder
.UseIdentity()
.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}"); })
所以我想我正在使用默认顺序......
有谁知道我错过了什么?