HttpContext.User.Identity 在发布模式下不起作用

HttpContext.User.Identity doesn't work in release mode

我想使用 HttpContext.User.Identity,它在 Debug 中完美运行,但当我发布时它无法识别 Windows 用户。

这是launchsetting.json文件

{   "iisSettings": {
    "windowsAuthentication": true,
    "anonymousAuthentication": false,
    "iisExpress": {
      "applicationUrl": "http://localhost:53960/",
      "sslPort": 0
    }   },   "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "DataManager": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:53961/"
    }   } }

我目前使用的是.net core 2.0

更新:这是我的 appsettings.json 文件

{
  "ConnectionStrings": {
    "GlossaryConnection": "██████████████",
    "EmployeeConnection": "██████████████"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}

感谢@Zhi Lv我只需要检查IIS认证配置(打开IIS,select网站,双击认证,检查认证配置),确保Windows 身份验证已启用且匿名身份验证已禁用状态