Author : HASSAN MD TAREQ

Overview

  • An ASP.NET Core application is basically a console application that hosts a web server (Kestrel)
    • Starts executing from the entry point public static void Main() in Program class
    • The Main method is similar to the Main method of a console Applications
    • All the .NET Core applications basically are console application
    • We build other types of applications like MVC Web Application or Razor page application over the console app
  • The main purpose of the Program class is to configure the applications infrastructure
  • The program class creates the Web Host at the startup & then configures the logging, Dependency Injection Container. configuration system, Kestrel Web server, IIS Integration, etc.
  • The CreateDefaultBuilder() method creates a new instance of WebHostBuilder with pre-configured defaults
  • Links

Program.cs

    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => {
                    webBuilder.UseStartup<Startup>();
            });
    }

Serilog integration

Logger initialization in Program class

Seeding database

Database Seeder