C# Kestrel上的身份验证失败,但IIS Express上的身份验证失败
我是.net core新手,正在尝试使用asp.net core中提供的身份验证功能的登录页面的web应用程序 当我创建并构建web应用程序时,我使用IISExpress运行它,身份验证功能正常工作,允许我登录并使用web应用程序上的各种操作 我现在正试图从IIExpress改为Kestrel,在登录时验证用户时遇到了一些困难C# Kestrel上的身份验证失败,但IIS Express上的身份验证失败,c#,asp.net-core,C#,Asp.net Core,我是.net core新手,正在尝试使用asp.net core中提供的身份验证功能的登录页面的web应用程序 当我创建并构建web应用程序时,我使用IISExpress运行它,身份验证功能正常工作,允许我登录并使用web应用程序上的各种操作 我现在正试图从IIExpress改为Kestrel,在登录时验证用户时遇到了一些困难 info: RestartTool.Controllers.AccountController[0] User logged in. info: Microsoft.
info: RestartTool.Controllers.AccountController[0]
User logged in.
info: Microsoft.AspNetCore.Mvc.RedirectToActionResult[1]
Executing RedirectResult, redirecting to /.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action RestartTool.Controllers.AccountController.Login (RestartTool) in 3330.8233ms
因此,当使用Kestrel时,用户“登录”正确,因为输入的用户/密码是正确的。因此,它意味着重定向到索引,或/
Request starting HTTP/1.1 GET http://localhost:59211/
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
Authorization failed for user: (null).
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
info: Microsoft.AspNetCore.Mvc.ChallengeResult[1]
Executing ChallengeResult with authentication schemes ().
但是,上面的错误消息出现在控制台中,页面最终重定向回登录页面,而用户没有登录
在我的startup-Configure方法中,我添加了下面一行,许多答案似乎都将修复显示为,但这并没有什么区别(因为它已经存在了)
如果它有用的话,在我的ConfigureServices方法中,我的设置如下:(再加一点来指定密码设置)
我基本上是按照本教程创建的,我不相信会有太多的变化:我已经通过在II Express页面上注销解决了这个问题,然后它能够让我登录并在Kestrel上成功运行身份验证。您可以添加将用户设置为已授权的代码行吗?
app.UseAuthentication();
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
/* services.ConfigureApplicationCookie(options =>
{
// Cookie settings
options.Cookie.HttpOnly = true;
options.Cookie.Expiration = TimeSpan.FromDays(150);
options.LoginPath = "/Account/Login"; // If the LoginPath is not set here, ASP.NET Core will default to /Account/Login
options.LogoutPath = "/Account/Logout"; // If the LogoutPath is not set here, ASP.NET Core will default to /Account/Logout
options.AccessDeniedPath = "/Account/AccessDenied"; // If the AccessDeniedPath is not set here, ASP.NET Core will default to /Account/AccessDenied
options.SlidingExpiration = true;
});*/