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



我想使用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

Upd:这是我的appsettings.json文件

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

多亏了@Zhi Lv,我只需要检查IIS身份验证配置(打开IIS,选择网站,双击身份验证,然后检查身份验证配置(,确保Windows身份验证处于启用状态,匿名身份验证处于禁用状态

最新更新