【发布时间】:2021-07-01 17:14:03
【问题描述】:
我想使用 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"
}
}
}
【问题讨论】:
-
“ASPNETCORE_ENVIRONMENT”:“生产”? docs.microsoft.com/pl-pl/aspnet/core/fundamentals/…
-
不,它不起作用
-
您是否在发布模式下通过 Visual Studio 运行应用程序?因为,这并不是 lauchSettings.json 真正要支持的……另一方面,appSettings.json 是为了支持在 VS 之外运行应用程序。
-
更新:添加 appsettings.json
-
您在哪里部署应用程序? IIS?如果应用宿主在 IIS 上,请检查 IIS Authentication 配置(打开 IIS,选择网站,双击 Authentication,勾选authentication configuration),确保 Windows Authentication 为 Enabled,Anonymous Authentication 为 Disabled 状态。跨度>
标签: .net asp.net-core asp.net-identity