React to WebListener configuration changes.

This commit is contained in:
Chris R 2016-04-16 23:27:55 -07:00
Родитель e72c9e3e46
Коммит 8e4580f956
2 изменённых файлов: 17 добавлений и 13 удалений

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

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Net.Http.Server;
namespace MusicStore
{
@ -6,14 +7,27 @@ namespace MusicStore
{
public static void Main(string[] args)
{
var host = 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")
.UseDefaultHostingConfiguration(args)
.UseIISIntegration()
.UseStartup("MusicStore")
.Build();
.UseStartup("MusicStore");
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.WebListener", System.StringComparison.Ordinal)
&& string.Equals(builder.GetSetting("environment"), "NtlmAuthentication", 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 =>
{
options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM;
});
}
var host = builder.Build();
host.Run();
}

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

@ -102,16 +102,6 @@ namespace MusicStore
// request pipeline.
// Note: Not recommended for production.
app.UseDeveloperExceptionPage();
// 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.
var listener = app.ServerFeatures.Get<WebListener>();
if (listener != null)
{
listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM;
}
app.UseDatabaseErrorPage();
// Add the runtime information page that can be used by developers