Migrate .NET Core v2 MVC app to v3

For migrating your .NET Core v2 MVC app to v3 use the following steps
  1. Change the .NET Core version of your web app to .NET Core v3.1 or higher
  2. Change your Startup.cs in your web root
    1. Remove the following line
      services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
    2. Add the following line to the ConfigureServices method
      services.AddControllersWithViews();
    3. Change the signature of method from
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      to
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    4. If you use a env.IsDevelopment() statement add the following in the top of your Startup.cs
      using Microsoft.Extensions.Hosting;
    5. Add the following lines to the bottom of your Configure method
      app.UseRouting();
      app.UseCors();
    6. Only add the following lines if you use authentication / authorization
      app.UseAuthentication();
      app.UseAuthorization();
    7. Convert your web routes from
      app.UseMvc(routes =>
      {
               routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
       });

      To
      app.UseEndpoints(endpoints =>
      {
         endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
      });
  3. Remove the Microsoft.AspNetCore.Razor.Design nuget package

Comments

Popular posts from this blog

System.Net.Http dll version problems

SharePoint Survey Back Button

How to set up AD FS for a development machine