Monday, September 20, 2021

Upgrade to ASP.NET 5.0

ASP.NET Core 5.0 Runtime (v5.0.10) - Windows Hosting Bundle Installer!

I upgraded one of my websites from .NET Core 2.1 to .NET 5. The experience was quite smooth. It took me about 1 hour to upgrade and publish it back to the web hosting vendor. 

Here are the steps:

1. Download ASP.NET Core 5.0 Runtime from the link  for dotnet-hosting-5.0.10-win.exe

2. Update Target framework to from .NET Core 2.1 to .NET 5.0.

3. HostingEnvironment is obsolete. Need to replace it with IWebHostEnvironment.

4. Replace UseMvc() with UseEndpoints(). Here are the details


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
            // Obsolet: app.UseMvc();
            // https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio
            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                // mvc
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}");

                endpoints.MapRazorPages();
            });

I used Visual Studio 2022, version 17 preview 4.0 for the upgrading. As of now, Microsoft hasn't published .NET 6, which is scheduled be published along with Visual Studio 2022 in October, 2021. Overall, the upgrade experience is very quick!

Cheers!

Thumbs Up to GitHub Copilot and JetBrains Resharper

Having used AI tool GitHub Copilot since 08/16/2023, I’ve realized that learning GitHub Copilot is like learning a new framework or library ...