From 40e87abdc0d353db870f86416e521845792d0387 Mon Sep 17 00:00:00 2001 From: Junvic Date: Sun, 22 May 2022 02:35:02 +0800 Subject: [PATCH] Update project to .NET 6 - Bump packages to latest versions - Use correct endpoint routing in Startup - Change bitness in launch settings to use "Default" --- WebPushDemo/Properties/launchSettings.json | 3 +-- WebPushDemo/Startup.cs | 17 ++++++++++------- WebPushDemo/WebPushDemo.csproj | 19 ++++++++++++------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/WebPushDemo/Properties/launchSettings.json b/WebPushDemo/Properties/launchSettings.json index 4c56f21..de3393b 100644 --- a/WebPushDemo/Properties/launchSettings.json +++ b/WebPushDemo/Properties/launchSettings.json @@ -19,8 +19,7 @@ "launchUrl": "http://localhost:50302/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - }, - "use64Bit": false + } } } } \ No newline at end of file diff --git a/WebPushDemo/Startup.cs b/WebPushDemo/Startup.cs index 49b8119..bdb7da1 100644 --- a/WebPushDemo/Startup.cs +++ b/WebPushDemo/Startup.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.EntityFrameworkCore; using WebPushDemo.Models; +using Microsoft.Extensions.Hosting; namespace WebPushDemo { @@ -32,7 +33,7 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { @@ -46,23 +47,25 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseStaticFiles(); + app.UseRouting(); + if (Configuration.GetSection("VapidKeys")["PublicKey"].Length == 0 || Configuration.GetSection("VapidKeys")["PrivateKey"].Length == 0) { - app.UseMvc(routes => + app.UseEndpoints(endpoints => { - routes.MapRoute( + endpoints.MapControllerRoute( name: "default", - template: "{controller=WebPush}/{action=GenerateKeys}/{id?}"); + pattern: "{controller=WebPush}/{action=GenerateKeys}/{id?}"); }); return; } - app.UseMvc(routes => + app.UseEndpoints(endpoints => { - routes.MapRoute( + endpoints.MapControllerRoute( name: "default", - template: "{controller=Devices}/{action=Index}/{id?}"); + pattern: "{controller=Devices}/{action=Index}/{id?}"); }); } } diff --git a/WebPushDemo/WebPushDemo.csproj b/WebPushDemo/WebPushDemo.csproj index f70fbe6..bcd1908 100644 --- a/WebPushDemo/WebPushDemo.csproj +++ b/WebPushDemo/WebPushDemo.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + net6.0 @@ -13,12 +13,17 @@ - - - - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + +