concept Program.cs in category asp.net

appears as: Program.cs
ASP.NET Core in Action

This is an excerpt from Manning's book ASP.NET Core in Action.

  • Program.cs defines the static void Main entry point for your application. This function is run when your app starts, the same as for console applications.
  • Program.cs is where you build an IWebHost instance, using a WebHostBuilder. The helper method, WebHost.CreateDefaultBuilder() can be used to create a WebHostBuilder that uses the Kestrel HTTP server, loads configuration settings, sets up logging, and adds IIS integration if necessary. Calling Build() creates the IWebHost instance.
  • ASP.NET Core identifies the current environment by using, perhaps unsurprisingly, an environment variable! The WebHostBuilder created in Program.cs looks for a magic environment variable called ASPNETCORE_ENVIRONMENT and uses it to create an IHostingEnvironment object.