From 0668e4541356a612f4d03faca985cd4e37156174 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 18 Apr 2016 13:36:52 -0700 Subject: [PATCH] Clean up server configuration. --- src/MusicStore/Program.cs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/MusicStore/Program.cs b/src/MusicStore/Program.cs index cc49ac2cbf..2c422547ae 100644 --- a/src/MusicStore/Program.cs +++ b/src/MusicStore/Program.cs @@ -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();