Modify Startup to run the right servers

This commit is contained in:
Pranav K 2016-04-28 14:48:23 -07:00
Родитель 838146c4a9
Коммит 849fc0e89f
2 изменённых файлов: 42 добавлений и 28 удалений

Просмотреть файл

@ -15,18 +15,16 @@ namespace MusicStore.Standalone
.Build(); .Build();
var builder = new WebHostBuilder() 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) .UseConfiguration(config)
.UseIISIntegration() .UseIISIntegration()
.UseStartup("MusicStore.Standalone"); .UseStartup("MusicStore.Standalone");
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal) && if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal))
(string.Equals(builder.GetSetting("environment") ?? {
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), var environment = builder.GetSetting("environment") ??
"NtlmAuthentication", Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
System.StringComparison.Ordinal)))
if (string.Equals(environment, "NtlmAuthentication", System.StringComparison.Ordinal))
{ {
// Set up NTLM authentication for WebListener like below. // Set up NTLM authentication for WebListener like below.
// For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or // For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or
@ -36,6 +34,15 @@ namespace MusicStore.Standalone
options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM;
}); });
} }
else
{
builder.UseWebListener();
}
}
else
{
builder.UseKestrel();
}
var host = builder.Build(); var host = builder.Build();

Просмотреть файл

@ -15,18 +15,16 @@ namespace MusicStore
.Build(); .Build();
var builder = new WebHostBuilder() 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) .UseConfiguration(config)
.UseIISIntegration() .UseIISIntegration()
.UseStartup("MusicStore"); .UseStartup("MusicStore");
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal) && if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal))
(string.Equals(builder.GetSetting("environment") ?? {
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), var environment = builder.GetSetting("environment") ??
"NtlmAuthentication", Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
System.StringComparison.Ordinal)))
if (string.Equals(environment, "NtlmAuthentication", System.StringComparison.Ordinal))
{ {
// Set up NTLM authentication for WebListener like below. // Set up NTLM authentication for WebListener like below.
// For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or // For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or
@ -36,6 +34,15 @@ namespace MusicStore
options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM;
}); });
} }
else
{
builder.UseWebListener();
}
}
else
{
builder.UseKestrel();
}
var host = builder.Build(); var host = builder.Build();