Clean up server configuration.
This commit is contained in:
parent
909be6d307
commit
0668e45413
|
|
@ -8,23 +8,31 @@ namespace MusicStore
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = new WebHostBuilder()
|
||||
// We set the server by name before default args so that command line arguments can override it.
|
||||
// This is used to allow deployers to choose the server for testing.
|
||||
.UseServer("Microsoft.AspNetCore.Server.Kestrel")
|
||||
.UseDefaultHostingConfiguration(args)
|
||||
.UseIISIntegration()
|
||||
.UseStartup("MusicStore");
|
||||
|
||||
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal)
|
||||
&& string.Equals(builder.GetSetting("environment"), "NtlmAuthentication", System.StringComparison.Ordinal))
|
||||
// Switch beteween Kestrel and WebListener for different tests. Default to Kestrel for normal app execution.
|
||||
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal))
|
||||
{
|
||||
// Set up NTLM authentication for WebListener like below.
|
||||
// For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or
|
||||
// modify the applicationHost.config to enable NTLM.
|
||||
builder.UseWebListener(options =>
|
||||
if (string.Equals(builder.GetSetting("environment"), "NtlmAuthentication", System.StringComparison.Ordinal))
|
||||
{
|
||||
options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM;
|
||||
});
|
||||
// Set up NTLM authentication for WebListener as follows.
|
||||
// For IIS and IISExpress use inetmgr to setup NTLM authentication on the application or
|
||||
// modify the applicationHost.config to enable NTLM.
|
||||
builder.UseWebListener(options =>
|
||||
{
|
||||
options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.UseWebListener();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.UseKestrel();
|
||||
}
|
||||
|
||||
var host = builder.Build();
|
||||
|
|
|
|||
Loading…
Reference in New Issue