From f2066234b0102e2ff004085a75a15fb7ec4c20ef Mon Sep 17 00:00:00 2001 From: Mark J Price Date: Tue, 15 Mar 2022 11:01:57 +0000 Subject: [PATCH] Initial commit --- .../Server/Northwind.BlazorWasm.Server.csproj | 2 +- .../Northwind.Mvc/Northwind.Mvc.csproj | 16 +++++++++++----- vs4win/PracticalApps/Northwind.Mvc/Program.cs | 5 +++++ .../Northwind.Web/Northwind.Web.csproj | 4 +++- vs4win/PracticalApps/Northwind.Web/Program.cs | 11 +++++++++++ .../PracticalApps/Northwind.Web/appsettings.json | 3 ++- .../Northwind.WebApi/Northwind.WebApi.csproj | 4 ++++ vs4win/PracticalApps/Northwind.WebApi/Program.cs | 10 ++++++++++ .../Northwind.WebApi/appsettings.json | 3 ++- .../Server/Northwind.BlazorWasm.Server.csproj | 2 +- .../Northwind.Mvc/Northwind.Mvc.csproj | 16 +++++++++++----- vscode/PracticalApps/Northwind.Mvc/Program.cs | 5 +++++ .../Northwind.Web/Northwind.Web.csproj | 4 +++- vscode/PracticalApps/Northwind.Web/Program.cs | 11 +++++++++++ .../PracticalApps/Northwind.Web/appsettings.json | 3 ++- .../Northwind.WebApi/Northwind.WebApi.csproj | 4 ++++ vscode/PracticalApps/Northwind.WebApi/Program.cs | 10 ++++++++++ .../Northwind.WebApi/appsettings.json | 3 ++- 18 files changed, 98 insertions(+), 18 deletions(-) diff --git a/vs4win/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj b/vs4win/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj index f12c2b8..e7ba393 100644 --- a/vs4win/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj +++ b/vs4win/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj @@ -7,7 +7,7 @@ - + diff --git a/vs4win/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj b/vs4win/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj index 2dd8550..c78c3b2 100644 --- a/vs4win/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj +++ b/vs4win/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj @@ -8,11 +8,11 @@ - - - - - + + + + + @@ -24,4 +24,10 @@ + + + + diff --git a/vs4win/PracticalApps/Northwind.Mvc/Program.cs b/vs4win/PracticalApps/Northwind.Mvc/Program.cs index 396fbf8..095799c 100644 --- a/vs4win/PracticalApps/Northwind.Mvc/Program.cs +++ b/vs4win/PracticalApps/Northwind.Mvc/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Identity; // IdentityUser using Microsoft.EntityFrameworkCore; // UseSqlServer, UseSqlite using Northwind.Mvc.Data; // ApplicationDbContext using Packt.Shared; // AddNorthwindContext extension method +using System.Net; using System.Net.Http.Headers; // MediaTypeWithQualityHeaderValue // Section 2 - configure the host web server including services @@ -40,7 +41,11 @@ builder.Services.AddNorthwindContext(); builder.Services.AddHttpClient(name: "Northwind.WebApi", configureClient: options => { + options.DefaultRequestVersion = HttpVersion.Version30; + options.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrLower; + options.BaseAddress = new Uri("https://localhost:5002/"); + options.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( mediaType: "application/json", quality: 1.0)); diff --git a/vs4win/PracticalApps/Northwind.Web/Northwind.Web.csproj b/vs4win/PracticalApps/Northwind.Web/Northwind.Web.csproj index 5211fe7..a4f7af1 100644 --- a/vs4win/PracticalApps/Northwind.Web/Northwind.Web.csproj +++ b/vs4win/PracticalApps/Northwind.Web/Northwind.Web.csproj @@ -4,8 +4,10 @@ net7.0 enable enable - + + preview + true diff --git a/vs4win/PracticalApps/Northwind.Web/Program.cs b/vs4win/PracticalApps/Northwind.Web/Program.cs index 4c16536..46cadcb 100644 --- a/vs4win/PracticalApps/Northwind.Web/Program.cs +++ b/vs4win/PracticalApps/Northwind.Web/Program.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Server.Kestrel.Core; // HttpProtocols using Packt.Shared; // AddNorthwindContext extension method // configure services @@ -5,6 +6,16 @@ using Packt.Shared; // AddNorthwindContext extension method var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorPages(); builder.Services.AddNorthwindContext(); + +builder.WebHost.ConfigureKestrel((context, options) => +{ + options.ListenAnyIP(5001, listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; + listenOptions.UseHttps(); // HTTP/3 requires secure connections + }); +}); + var app = builder.Build(); // configure the HTTP pipeline diff --git a/vs4win/PracticalApps/Northwind.Web/appsettings.json b/vs4win/PracticalApps/Northwind.Web/appsettings.json index 10f68b8..b320cb0 100644 --- a/vs4win/PracticalApps/Northwind.Web/appsettings.json +++ b/vs4win/PracticalApps/Northwind.Web/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Information" } }, "AllowedHosts": "*" diff --git a/vs4win/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj b/vs4win/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj index 1c7bc15..73d280e 100644 --- a/vs4win/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj +++ b/vs4win/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj @@ -5,6 +5,10 @@ enable enable true + + + preview + true diff --git a/vs4win/PracticalApps/Northwind.WebApi/Program.cs b/vs4win/PracticalApps/Northwind.WebApi/Program.cs index 113e5a8..b0e7fc0 100644 --- a/vs4win/PracticalApps/Northwind.WebApi/Program.cs +++ b/vs4win/PracticalApps/Northwind.WebApi/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc.Formatters; // IOutputFormatter, OutputFormatter using Packt.Shared; // AddNorthwindContext extension method using Northwind.WebApi.Repositories; // ICustomerRepository, CustomerRepository using Swashbuckle.AspNetCore.SwaggerUI; +using Microsoft.AspNetCore.Server.Kestrel.Core; // HttpProtocols var builder = WebApplication.CreateBuilder(args); @@ -39,6 +40,15 @@ builder.Services.AddScoped(); builder.Services.AddHealthChecks() .AddDbContextCheck(); +builder.WebHost.ConfigureKestrel((context, options) => +{ + options.ListenAnyIP(5002, listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; + listenOptions.UseHttps(); // HTTP/3 requires secure connections + }); +}); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/vs4win/PracticalApps/Northwind.WebApi/appsettings.json b/vs4win/PracticalApps/Northwind.WebApi/appsettings.json index 10f68b8..b320cb0 100644 --- a/vs4win/PracticalApps/Northwind.WebApi/appsettings.json +++ b/vs4win/PracticalApps/Northwind.WebApi/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Information" } }, "AllowedHosts": "*" diff --git a/vscode/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj b/vscode/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj index f12c2b8..e7ba393 100644 --- a/vscode/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj +++ b/vscode/PracticalApps/Northwind.BlazorWasm/Server/Northwind.BlazorWasm.Server.csproj @@ -7,7 +7,7 @@ - + diff --git a/vscode/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj b/vscode/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj index 2dd8550..c78c3b2 100644 --- a/vscode/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj +++ b/vscode/PracticalApps/Northwind.Mvc/Northwind.Mvc.csproj @@ -8,11 +8,11 @@ - - - - - + + + + + @@ -24,4 +24,10 @@ + + + + diff --git a/vscode/PracticalApps/Northwind.Mvc/Program.cs b/vscode/PracticalApps/Northwind.Mvc/Program.cs index 396fbf8..095799c 100644 --- a/vscode/PracticalApps/Northwind.Mvc/Program.cs +++ b/vscode/PracticalApps/Northwind.Mvc/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Identity; // IdentityUser using Microsoft.EntityFrameworkCore; // UseSqlServer, UseSqlite using Northwind.Mvc.Data; // ApplicationDbContext using Packt.Shared; // AddNorthwindContext extension method +using System.Net; using System.Net.Http.Headers; // MediaTypeWithQualityHeaderValue // Section 2 - configure the host web server including services @@ -40,7 +41,11 @@ builder.Services.AddNorthwindContext(); builder.Services.AddHttpClient(name: "Northwind.WebApi", configureClient: options => { + options.DefaultRequestVersion = HttpVersion.Version30; + options.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrLower; + options.BaseAddress = new Uri("https://localhost:5002/"); + options.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( mediaType: "application/json", quality: 1.0)); diff --git a/vscode/PracticalApps/Northwind.Web/Northwind.Web.csproj b/vscode/PracticalApps/Northwind.Web/Northwind.Web.csproj index 5211fe7..a4f7af1 100644 --- a/vscode/PracticalApps/Northwind.Web/Northwind.Web.csproj +++ b/vscode/PracticalApps/Northwind.Web/Northwind.Web.csproj @@ -4,8 +4,10 @@ net7.0 enable enable - + + preview + true diff --git a/vscode/PracticalApps/Northwind.Web/Program.cs b/vscode/PracticalApps/Northwind.Web/Program.cs index 4c16536..46cadcb 100644 --- a/vscode/PracticalApps/Northwind.Web/Program.cs +++ b/vscode/PracticalApps/Northwind.Web/Program.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Server.Kestrel.Core; // HttpProtocols using Packt.Shared; // AddNorthwindContext extension method // configure services @@ -5,6 +6,16 @@ using Packt.Shared; // AddNorthwindContext extension method var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorPages(); builder.Services.AddNorthwindContext(); + +builder.WebHost.ConfigureKestrel((context, options) => +{ + options.ListenAnyIP(5001, listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; + listenOptions.UseHttps(); // HTTP/3 requires secure connections + }); +}); + var app = builder.Build(); // configure the HTTP pipeline diff --git a/vscode/PracticalApps/Northwind.Web/appsettings.json b/vscode/PracticalApps/Northwind.Web/appsettings.json index 10f68b8..b320cb0 100644 --- a/vscode/PracticalApps/Northwind.Web/appsettings.json +++ b/vscode/PracticalApps/Northwind.Web/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Information" } }, "AllowedHosts": "*" diff --git a/vscode/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj b/vscode/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj index 1c7bc15..73d280e 100644 --- a/vscode/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj +++ b/vscode/PracticalApps/Northwind.WebApi/Northwind.WebApi.csproj @@ -5,6 +5,10 @@ enable enable true + + + preview + true diff --git a/vscode/PracticalApps/Northwind.WebApi/Program.cs b/vscode/PracticalApps/Northwind.WebApi/Program.cs index 113e5a8..b0e7fc0 100644 --- a/vscode/PracticalApps/Northwind.WebApi/Program.cs +++ b/vscode/PracticalApps/Northwind.WebApi/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc.Formatters; // IOutputFormatter, OutputFormatter using Packt.Shared; // AddNorthwindContext extension method using Northwind.WebApi.Repositories; // ICustomerRepository, CustomerRepository using Swashbuckle.AspNetCore.SwaggerUI; +using Microsoft.AspNetCore.Server.Kestrel.Core; // HttpProtocols var builder = WebApplication.CreateBuilder(args); @@ -39,6 +40,15 @@ builder.Services.AddScoped(); builder.Services.AddHealthChecks() .AddDbContextCheck(); +builder.WebHost.ConfigureKestrel((context, options) => +{ + options.ListenAnyIP(5002, listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; + listenOptions.UseHttps(); // HTTP/3 requires secure connections + }); +}); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/vscode/PracticalApps/Northwind.WebApi/appsettings.json b/vscode/PracticalApps/Northwind.WebApi/appsettings.json index 10f68b8..b320cb0 100644 --- a/vscode/PracticalApps/Northwind.WebApi/appsettings.json +++ b/vscode/PracticalApps/Northwind.WebApi/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Information" } }, "AllowedHosts": "*"