Fix WebListenerOptionsSetup service registration
This commit is contained in:
parent
ff95748d7e
commit
6b0684cc4d
|
|
@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
|
using Microsoft.AspNetCore.Server.WebListener;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Net.Http.Server;
|
using Microsoft.Net.Http.Server;
|
||||||
|
|
||||||
|
|
@ -13,6 +15,15 @@ namespace SelfHostServer
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
// Server options can be configured here instead of in Main.
|
||||||
|
services.Configure<WebListenerOptions>(options =>
|
||||||
|
{
|
||||||
|
options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.AllowAnonymous;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
|
||||||
{
|
{
|
||||||
loggerfactory.AddConsole(LogLevel.Debug);
|
loggerfactory.AddConsole(LogLevel.Debug);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,10 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IWebHostBuilder UseWebListener(this IWebHostBuilder hostBuilder)
|
public static IWebHostBuilder UseWebListener(this IWebHostBuilder hostBuilder)
|
||||||
{
|
{
|
||||||
return hostBuilder.ConfigureServices(services => services.AddSingleton<IServer, MessagePump>());
|
return hostBuilder.ConfigureServices(services => {
|
||||||
|
services.AddTransient<IConfigureOptions<WebListenerOptions>, WebListenerOptionsSetup>();
|
||||||
|
services.AddSingleton<IServer, MessagePump>();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -59,7 +62,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
hostBuilder.ConfigureServices(services =>
|
hostBuilder.ConfigureServices(services =>
|
||||||
{
|
{
|
||||||
services.AddTransient<IConfigureOptions<WebListenerOptions>, WebListenerOptionsSetup>();
|
|
||||||
services.Configure(options);
|
services.Configure(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue