How Asp.net Core Application Starts as a Console Application and Converts to a Web Application | Main Method in Asp.net Core | Part-3
Hello and As-Salaam U Alikum! , In this article we will learn about the main method in Asp.net Core.
In the Previous articles we have created so many asp.net core projects but I didn't emphasis on a file which name is "Program.cs" . Yes we are going to discuss it now.
whether you open any type of project e.g. (mvc,empty,web api etc) ,you will surely find this file in your solution explorer. just double click it , you will find two static methods in that file .
- Main()
- CreateWebHostBuilder()
As we can clearly see that there is a method CreateWebHostBuilder() main method. This method returns an object that implements the IWebHostBuilder interface.
object of IWebHostBuilder initially calls build() method which build a web host and host our asp.net core web application on that web host.
secondary it calls the Run() method which starts the application for listening incoming http requests.
what CreateDefaultBuilder does ?
- Establishing Web Server
- Application & host Configuration from different configuration sources.
- Configuring Logging
OK, now lets discuss hosting point of view. Asp.net Core hosting can be done in two ways .
- In Process
- Out Process
While establishing a webhost "Startup.cs" class also configured using extension method of IWebHostBuilder .
n the startup.cs file we have two methods.
- ConfigureServices()
- Configure()
The ConfigureServices() method of the startup class configures the services that are required by the application. The Configure() method of the startup class sets the application's pipeline of request processing. In a later article, we will discuss both of these methods in detail.
0 Comments:
Post a Comment
Do not Add Spam links in the Comment Box
Subscribe to Post Comments [Atom]
<< Home