From 5c14d05fc2a7c5eb81722f41aa6a905abcafbee3 Mon Sep 17 00:00:00 2001 From: Kirk Larkin <6025110+serpent5@users.noreply.github.com> Date: Fri, 26 Nov 2021 17:43:51 +0000 Subject: [PATCH] Update Kestrel Overview to 6.0 (#24079) * Update Kestrel Overview to 6.0 * . * . * . * . --- aspnetcore/fundamentals/servers/kestrel.md | 8 +++---- .../fundamentals/servers/kestrel/http3.md | 2 +- .../6.x/Http3Sample/Http3Sample.csproj | 7 ------ .../samples/6.x/Http3Sample/Program.cs | 22 ------------------- .../6.x/KestrelSample/KestrelSample.csproj | 10 +++++++++ .../samples/6.x/KestrelSample/Program.cs | 8 +++++++ .../6.x/KestrelSample/Snippets/Program.cs | 22 +++++++++++++++++++ .../appsettings.Development.json | 8 +++++++ .../6.x/KestrelSample/appsettings.json | 9 ++++++++ 9 files changed, 61 insertions(+), 35 deletions(-) delete mode 100644 aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Http3Sample.csproj delete mode 100644 aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Program.cs create mode 100644 aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/KestrelSample.csproj create mode 100644 aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Program.cs create mode 100644 aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs create mode 100644 aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.Development.json create mode 100644 aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.json diff --git a/aspnetcore/fundamentals/servers/kestrel.md b/aspnetcore/fundamentals/servers/kestrel.md index 55e9e9c3a3..ace50457aa 100644 --- a/aspnetcore/fundamentals/servers/kestrel.md +++ b/aspnetcore/fundamentals/servers/kestrel.md @@ -28,15 +28,13 @@ Kestrel supports the following scenarios: Kestrel is supported on all platforms and versions that .NET Core supports. -[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/fundamentals/servers/kestrel/samples/5.x) ([how to download](xref:index#how-to-download-a-sample)) - ## Get started -ASP.NET Core project templates use Kestrel by default when not hosted with IIS. In *Program.cs*, the method calls : +ASP.NET Core project templates use Kestrel by default when not hosted with IIS. In *Program.cs*, the method calls : -:::code language="csharp" source="kestrel/samples/5.x/KestrelSample/Program.cs" id="snippet_DefaultBuilder" highlight="8"::: +:::code language="csharp" source="kestrel/samples/6.x/KestrelSample/Program.cs" id="snippet_CreateBuilder" highlight="1"::: -For more information on building the host, see the *Set up a host* and *Default builder settings* sections of . +For more information on configuring `WebApplication` and `WebApplicationBuilder`, see . ## Optional client certificates diff --git a/aspnetcore/fundamentals/servers/kestrel/http3.md b/aspnetcore/fundamentals/servers/kestrel/http3.md index 912fb9d07c..f4972611dc 100644 --- a/aspnetcore/fundamentals/servers/kestrel/http3.md +++ b/aspnetcore/fundamentals/servers/kestrel/http3.md @@ -49,7 +49,7 @@ HTTP/3 isn't currently supported on macOS and may be available in a future relea HTTP/3 is not enabled by default. Add configuration to *Program.cs* to enable HTTP/3. -[!code-csharp[](samples/6.x/Http3Sample/Program.cs?name=snippet_UseHttp3&highlight=7-8)] +:::code language="csharp" source="samples/6.x/KestrelSample/Snippets/Program.cs" id="snippet_Http3" highlight="7-8"::: The preceding code configures port 5001 to: diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Http3Sample.csproj b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Http3Sample.csproj deleted file mode 100644 index e948168d32..0000000000 --- a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Http3Sample.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - net6.0 - - - diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Program.cs b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Program.cs deleted file mode 100644 index 1b29267835..0000000000 --- a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/Http3Sample/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Net; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Server.Kestrel.Core; - -#region snippet_UseHttp3 -var builder = WebApplication.CreateBuilder(args); -builder.WebHost.ConfigureKestrel((context, options) => -{ - options.ListenAnyIP(5001, listenOptions => - { - // Use HTTP/3 - listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; - listenOptions.UseHttps(); - }); -}); -#endregion -await using var app = builder.Build(); -app.MapGet("/", () => "Hello World!"); -await app.RunAsync(); \ No newline at end of file diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/KestrelSample.csproj b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/KestrelSample.csproj new file mode 100644 index 0000000000..280245712d --- /dev/null +++ b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/KestrelSample.csproj @@ -0,0 +1,10 @@ + + + + net6.0 + enable + enable + True + + + diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Program.cs b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Program.cs new file mode 100644 index 0000000000..544f1f3f0d --- /dev/null +++ b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Program.cs @@ -0,0 +1,8 @@ +// +var builder = WebApplication.CreateBuilder(args); +var app = builder.Build(); + +app.MapGet("/", () => "Hello World!"); + +app.Run(); +// diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs new file mode 100644 index 0000000000..e4f00bc4df --- /dev/null +++ b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Server.Kestrel.Core; + +namespace KestrelSample.Snippets; + +public static class Program +{ + public static void Http3(string[] args) + { + // + var builder = WebApplication.CreateBuilder(args); + + builder.WebHost.ConfigureKestrel((context, options) => + { + options.ListenAnyIP(5001, listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; + listenOptions.UseHttps(); + }); + }); + // + } +} diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.Development.json b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.Development.json new file mode 100644 index 0000000000..0c208ae918 --- /dev/null +++ b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.json b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.json new file mode 100644 index 0000000000..10f68b8c8b --- /dev/null +++ b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}