diff --git a/samples/Http2SampleApp/Program.cs b/samples/Http2SampleApp/Program.cs index acf22dc01c..0aee02c7a7 100644 --- a/samples/Http2SampleApp/Program.cs +++ b/samples/Http2SampleApp/Program.cs @@ -24,7 +24,8 @@ namespace Http2SampleApp factory.SetMinimumLevel(LogLevel.Trace); factory.AddConsole(); }) - .UseKestrel((context, options) => + .UseKestrel() + .ConfigureKestrel((context, options) => { var basePort = context.Configuration.GetValue("BASE_PORT") ?? 5000; diff --git a/src/Kestrel/WebHostBuilderKestrelExtensions.cs b/src/Kestrel/WebHostBuilderKestrelExtensions.cs index 6552da10f2..62411b168d 100644 --- a/src/Kestrel/WebHostBuilderKestrelExtensions.cs +++ b/src/Kestrel/WebHostBuilderKestrelExtensions.cs @@ -50,7 +50,24 @@ namespace Microsoft.AspNetCore.Hosting /// public static IWebHostBuilder UseKestrel(this IWebHostBuilder hostBuilder, Action options) { - return hostBuilder.UseKestrel().ConfigureServices(services => + return hostBuilder.UseKestrel().ConfigureKestrel(options); + } + + /// + /// Configures Kestrel options but does not register an IServer. See . + /// + /// + /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder to configure. + /// + /// + /// A callback to configure Kestrel options. + /// + /// + /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder. + /// + public static IWebHostBuilder ConfigureKestrel(this IWebHostBuilder hostBuilder, Action options) + { + return hostBuilder.ConfigureServices(services => { services.Configure(options); }); @@ -67,13 +84,28 @@ namespace Microsoft.AspNetCore.Hosting /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder. /// public static IWebHostBuilder UseKestrel(this IWebHostBuilder hostBuilder, Action configureOptions) + { + return hostBuilder.UseKestrel().ConfigureKestrel(configureOptions); + } + + /// + /// Configures Kestrel options but does not register an IServer. See . + /// + /// + /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder to configure. + /// + /// A callback to configure Kestrel options. + /// + /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder. + /// + public static IWebHostBuilder ConfigureKestrel(this IWebHostBuilder hostBuilder, Action configureOptions) { if (configureOptions == null) { throw new ArgumentNullException(nameof(configureOptions)); } - return hostBuilder.UseKestrel().ConfigureServices((context, services) => + return hostBuilder.ConfigureServices((context, services) => { services.Configure(options => {