【发布时间】: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 = true 和 AutomaticChallenge = 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