From 849fc0e89fac7702e362ff149eaa7dd5effb286c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 28 Apr 2016 14:48:23 -0700 Subject: [PATCH] Modify Startup to run the right servers --- src/MusicStore.Standalone/Program.cs | 35 +++++++++++++++++----------- src/MusicStore/Program.cs | 35 +++++++++++++++++----------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/MusicStore.Standalone/Program.cs b/src/MusicStore.Standalone/Program.cs index 025741c..e915ca4 100644 --- a/src/MusicStore.Standalone/Program.cs +++ b/src/MusicStore.Standalone/Program.cs @@ -15,26 +15,33 @@ namespace MusicStore.Standalone .Build(); 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") .UseConfiguration(config) .UseIISIntegration() .UseStartup("MusicStore.Standalone"); - if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal) && - (string.Equals(builder.GetSetting("environment") ?? - Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), - "NtlmAuthentication", - System.StringComparison.Ordinal))) + 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 => + var environment = builder.GetSetting("environment") ?? + Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + + if (string.Equals(environment, "NtlmAuthentication", System.StringComparison.Ordinal)) { - options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; - }); + // 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 => + { + options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; + }); + } + else + { + builder.UseWebListener(); + } + } + else + { + builder.UseKestrel(); } var host = builder.Build(); diff --git a/src/MusicStore/Program.cs b/src/MusicStore/Program.cs index 6f184fc..f65328f 100644 --- a/src/MusicStore/Program.cs +++ b/src/MusicStore/Program.cs @@ -15,26 +15,33 @@ namespace MusicStore .Build(); 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") .UseConfiguration(config) .UseIISIntegration() .UseStartup("MusicStore"); - if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal) && - (string.Equals(builder.GetSetting("environment") ?? - Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), - "NtlmAuthentication", - System.StringComparison.Ordinal))) + 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 => + var environment = builder.GetSetting("environment") ?? + Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + + if (string.Equals(environment, "NtlmAuthentication", System.StringComparison.Ordinal)) { - options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; - }); + // 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 => + { + options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; + }); + } + else + { + builder.UseWebListener(); + } + } + else + { + builder.UseKestrel(); } var host = builder.Build();