Step by step migration of ASP.NET Core 2.2 to 3.1

In order to upgrade/migrate core version to 3.1 following steps to be perform.

  • Download and install Visual Studio 2019 version 16.4 or higher.
  • Download and install .NET Core 3.1
  • Upgrade the projects of solution to .NET Core 3.1 , because ASP.NET Core 3.1 requires it.
  • Update existing Nuget packages to a version compatible with ASP.NET Core 3.1 in each project
  • Use IHost interface from a IHostBuilder instead of building and running a IWebHost from a IWebHostBuilder in Program.cs
  public static IHostBuilder CreateWebHostBuilder(string[] args) =>  
           .ConfigureWebHostDefaults(webBuilder =>  
  • Change AddMvc method has been replaced by AddControllers in Startup.cs of each projects.
  • In Startup.cs, UseMvc method to be replaced by UseRouting method and UseEndpoints method. Note that these two methods must not be nested if you are using Authentication and Authorization. UseRouting method must be set before UseAuthentication and UseAuthorization methods. UseEndpoints method has to be set at the end.
  • IHostingEnvironment to be replaced by IHostEnvironment in all projects 
  • Replace UseSignalR with UseEndpoint method in Startup.cs
 public class Startup  
     public Startup(IConfiguration configuration)  
       Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();  
       Configuration = configuration;  
     public IConfiguration Configuration { get; }  
     public void ConfigureServices(IServiceCollection services)  
       services.AddControllers().AddNewtonsoftJson(options =>   
         options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;  
         options.SerializerSettings.ContractResolver = new DefaultContractResolver();  
       services.AddHttpClient<IDataClient, DataClient>(client =>  
         client.BaseAddress = new Uri("http://localhost:4444/api/");  
     public void Configure(IApplicationBuilder app, IHostEnvironment env)  
       if (env.IsDevelopment())  
         app.UseEndpoints(endpoints =>  
       // Needs to be added after UseRouting() in 3.1  
       // app.UseAuthorization();   
       app.UseEndpoints(endpoints =>  


Popular posts from this blog

Restore the lost focus of Auto post back controls in update Panel control

Disable backspace key using Jquery

Clone a generic list in C# using extension method

Add Comma automatically while entering amounts in textbox using Javascript

Remove Owin from MVC 5 Application and use custom forms authentication

Source Code Beautifier And Format Source Code For Blogger and Websites

Email validation using regular expression in jQuery

Send bulk Email in using excel file