Windows 身份验证在调试时有效,但在服务器上无效,反之亦然
Windows Authentication works when debugging but not on server and vice versa
我的 .net 核心 asp mvc 应用程序中的 Windows 身份验证有一个奇怪的问题。
我最初在 Program.cs
中进行了此 BuildWebHost
设置:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseHttpSys(options =>
{
options.Authentication.Schemes =
AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate;
options.Authentication.AllowAnonymous = false;
})
.Build();
从 vscode 进行调试时,这工作得很好。
系统提示我以域用户身份登录,一切正常。
然而,当我发布到我的 Windows 7 "server" IIS 时,整个应用程序失败
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
所以我将 BuildWebHost
更改为
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
现在它在服务器上运行得很好,但是当我尝试从 vscode 进行调试时,我得到
InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
这很不方便,因为它可以工作,但每次我想发布或 test/debug 应用程序时,我都必须删除那部分代码。
我该如何解决这个问题,或者至少解决问题所在?
IIS 需要 Kestrel,它不适用于 HttpSys。不幸的是,Kestrel 没有它自己的 windows 授权,它依赖于 IIS。 IIS 是否为您的开发环境提供了一个选项?否则你需要做一些笨拙的事情来检测你在 main 中的环境并相应地选择你的服务器。
我的 .net 核心 asp mvc 应用程序中的 Windows 身份验证有一个奇怪的问题。
我最初在 Program.cs
中进行了此 BuildWebHost
设置:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseHttpSys(options =>
{
options.Authentication.Schemes =
AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate;
options.Authentication.AllowAnonymous = false;
})
.Build();
从 vscode 进行调试时,这工作得很好。
系统提示我以域用户身份登录,一切正常。
然而,当我发布到我的 Windows 7 "server" IIS 时,整个应用程序失败
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
所以我将 BuildWebHost
更改为
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
现在它在服务器上运行得很好,但是当我尝试从 vscode 进行调试时,我得到
InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
这很不方便,因为它可以工作,但每次我想发布或 test/debug 应用程序时,我都必须删除那部分代码。
我该如何解决这个问题,或者至少解决问题所在?
IIS 需要 Kestrel,它不适用于 HttpSys。不幸的是,Kestrel 没有它自己的 windows 授权,它依赖于 IIS。 IIS 是否为您的开发环境提供了一个选项?否则你需要做一些笨拙的事情来检测你在 main 中的环境并相应地选择你的服务器。