Authentication 403-禁止:访问被拒绝。登录ASP.Net Core 2.2后

Authentication 403-禁止:访问被拒绝。登录ASP.Net Core 2.2后,authentication,asp.net-core,cookies,Authentication,Asp.net Core,Cookies,我最近更换了主机服务器, 我在登录后随机收到此错误消息: 403-禁止:访问被拒绝 您没有使用您提供的凭据查看此目录或页面的权限 当我在浏览器中删除相关cookies时,网站会再次加载 我使用cookie身份验证,但不使用此处描述的ASP.NET核心标识: startup.cs代码: services.AddAuthentication(options => { options.DefaultAuthenticateScheme

我最近更换了主机服务器, 我在登录后随机收到此错误消息:

403-禁止:访问被拒绝

您没有使用您提供的凭据查看此目录或页面的权限

当我在浏览器中删除相关cookies时,网站会再次加载

我使用cookie身份验证,但不使用此处描述的ASP.NET核心标识:

startup.cs代码:

  services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            }).AddCookie(options =>
            {
                
                options.LoginPath = "/Login";
                options.LogoutPath = "/Logout";
                options.ExpireTimeSpan = TimeSpan.FromMinutes(43200);
            });
和登录部分代码:

            User user = await _userService.LoginUserAsync(login.Email, login.Password);
            var claims = new List<Claim>()
            {
                new Claim(ClaimTypes.Name,user.UserName),
                new Claim(ClaimTypes.NameIdentifier,user.UserID.ToString())
            };
            var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
            var pricipal = new ClaimsPrincipal(identity);

            var properties = new AuthenticationProperties()
            {
                IsPersistent = login.RememberMe
            };

            await HttpContext.SignInAsync(pricipal, properties);
User User=wait\u userService.LoginUserAsync(login.Email,login.Password);
var索赔=新列表()
{
新索赔(索赔类型.名称,用户.用户名),
新声明(ClaimTypes.NameIdentifier,user.UserID.ToString())
};
var identity=新的索赔实体(索赔、CookieAuthenticationDefaults.AuthenticationScheme);
var pricipal=新的索赔(身份);
var properties=newauthenticationproperties()
{
IsPersistent=login.RememberMe
};
等待HttpContext.SignInAsync(主要属性);
我以前的托管计划从来没有遇到过同样的问题


这个问题与主机设置有关吗?

我最近更改了我的主机服务器
原来的主机服务器是什么,现在是什么?你能分享更多的细节来一步一步地重现这个问题吗?这两个都是Windows服务器上的共享托管计划。在Plesk Tools>Failed Request Tracing中,我发现了一些与模块相关的东西:阻止请求的ModSecurity IIS。这个模块的错误配置会导致403错误吗?这篇文章可能会帮助你,看看。基本上,这是因为您没有正确设置自己的默认页面。