Learn MVC Core Bootstrapping and Request/Response process

Menka Chaugule
3 min readMay 28, 2020

--

Hello friends..!!! In this article we are going to learn about Bootstrapping and Request/Response process.

First we will see the Bootstrapping process.So let’s start…

Bootstrap Process

Bootstrap process is nothing but an execution process.

This process loads programs one at a time while each program is connected to the next program to be executed in sequence.

In below window,you can see that the project structure of a simple MVC ASP.NET Core project.

Project Structure

The bootstrap process starts when you start running the application.

The execution starts from Program.cs file.

1.Program.cs -

In Program.cs file we can create a host for the web application.

Program.cs File

In the above window,the Host is used to create instance of IHostBuilder.The CreateDefaultBuilder() method creates a new instance of HostBuilder and configures Kestrel web server,IIS and other configurations. Kestrel web server is an open-source, cross-platform web server for ASP.NET Core.

The Build() method returns an instance of Host and Run() method starts web application till it stops.

The UseStartup<Startup>() method specifies the Startup class to be used by the host.And then the control goes to the Startup.cs file.

2.Startup.cs -

The Startup.cs file is entry point of application level.It handles request pipeline.When application launches Startup class triggers first.This file is a replacement of Global.asax file in ASP.NET Core.

Startup.cs File

There are two methods in startup file, one is ConfigureServices and another is Configure.

ConfigureServices -

In Startup class ConfigureServices method is an optional method which is used to configure services for application.And this method must be declared with public access modifier.

This method includes IServiceCollection parameter to register services.

Configure -

This method is used to specify how the application will respond in each HTTP request.When we add some service in ConfigureService method, it will be available to Configure method to be used.For example,if we register UseMvc() method into Configure then we need to register service AddMvc() into ConfigureServices.

This method accepts IApplicationBuilder parameter with another services like IHostingEnvironment and ILoggerFactory.

The MapControllerRoute configures the controller by using path, “{controller=Home}/{action=Index}/{id?}”.It defines that default route is set to the HomeController and Action set to Index.The ‘?’ sign for the id defines that id is optional.

Request/Response Process

When end user or client send a request through browser it goes to the controller.The controller is a coordinator between model and view.The model handles the application’s domain data and the view is seen by users in a browser.

In the above diagram,when the controller receives a request from browser, it interacts with the model for data and send a response through the view.

For a better understanding must watch the below video

Thanks for reading..!!!

--

--