Initialization of .Net core Web Application
- No Global.asax
- Web application and other application starts from program class contains main method
- main method calls another static method CreateWebHostBuilder method that returns object of IWebHostBuilder interface.
- CreateWebHostBuilder calls CreateDefaultBuilder static method.
- That creates object of WebHostBuilder setup it and run it.
- Created object 'builder' of WebHostbuilder
- UseKestral(): Tells builder to use Kestrel.
Kestrel is embedded internal server that host application and communicate (Request/Response) with external web server like IIS. - UseIISIntegration(): Tells to use IIS and communication between IIS and Kestrel.
- UseContentRoot: Access project directory
- ConfigureAppConfiguration: Loads appSettings.json file contains settings
- ConfigureLogging: Configures logging in console window and debug window including in libraries used.
- UseDefaultServiceProvider: Tells builder to use asp.net core's internal dependency injection container.
- ConfigureServices: Used to add types to the internal dependency injection container. Adding type Kestrel that is used.
- Returns object of WebHostbuilder
- Object of WebHostBuilder configured to use Startup class.
- Startup Class: Contains 2 methods
- ConfigureServices: Used to register services in Ioc container
- Configure: Used to configure Request/Response pipeline
{
public void Configure(IApplicationBuilder app)
{
//Register types (services) to use in application
}
public void ConfigureServices(IServiceCollection services)
{
//Configure how to handle http request
}
}


No comments:
Post a Comment