Working with the Program class
The Program
class is the main entry point for ASP.NET Core 2.0 applications. In fact, ASP.NET Core 2.0 applications are very similar to standard .NET Framework console applications in this regard. Both have a Main
method that is executed when running the application. Even the basic signature of the Main
method, which accepts an array of strings as arguments, is the same, as you can see in the following code. To no surprise, this is due to the fact that an ASP.NET Core application is, in reality, a console application hosting a web application:
using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace TicTacToe { public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() ...