Changing the Startup class name

The name of the Startup class is a convention of ASP.NET Core applications. It is recommended to leave it as it is to make the code clearer for colleagues. However, there are a few situations where you are required to use a different name for the Startup class—for example, when Startup is already a class in your application but is responsible for an entirely different task than initializing ASP.NET Core.

On such occasions, open the Program class file, located in the root folder under Program.cs, and locate the CreateWebHostBuilder method. It should look similar to the following:

 public static IWebHostBuilder CreateWebHostBuiler(string[] args) =>    WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>(); ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.