Używam poniższy kod do uwierzytelniania w ASP.NET 2.0 z wykorzystaniem rdzenia ciasteczkaNie authenticationScheme został określony, i nie było DefaultChallengeScheme znaleźć uwierzytelniania Cookies
services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie("MyCookieMiddlewareInstance", options =>
{
options.AccessDeniedPath = new PathString("/Account/Login");
options.LoginPath = new PathString("/Account/Login");
options.LogoutPath = new PathString("/Account/LogOff");
});
ja otrzymuję błąd jako „Nie było authenticationScheme . określony, a nie znaleziono żadnych wiadomości DefaultChallengeScheme”
konfiguracja cookie jest poniżej:
var claims = new List<Claim>
{
new Claim(ClaimTypes.NameIdentifier, userId.ToString()),
new Claim(ClaimTypes.Name, userName)
};
var identity = new ClaimsIdentity(claims, "Forms");
identity.AddClaim(new Claim(ClaimTypes.Role, "ADMIN"));
var principal = new ClaimsPrincipal(identity);
HttpContext.Authentication.SignInAsync("MyCookieMiddlewareInstance", principal, new AuthenticationProperties
{
IsPersistent = isPersistent,
ExpiresUtc = DateTime.UtcNow.AddYears(1)
});
Zrobiłem trochę badań i nie znalazłem rozwiązania. Oto link, którego użyłem: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?tabs=aspnetcore2x
Czy ktoś może dać mi znać, w jaki sposób mogę rozwiązać ten problem?
Prawdopodobny duplikat oprogramowania pośredniczącego do uwierzytelniania ASP.NET Core 2.0] (https://stackoverflow.com/questions/ 45805411/middle-core-2-0-authentication-middleware) –