Total Page Preview:   000000000204

Explain dot net core request life cycle in English and Hindi

Request life cycle in English

The ASP.NET Core request life cycle refers to the series of steps that occur when a request is made to an ASP.NET Core application. Here's a simplified explanation of the request life cycle along with an example:

1-Startup: When the application starts, the Startup class is executed. It configures services and middleware required for handling requests.
2-Request Handling:
  • HTTP Request: A client sends an HTTP request to the ASP.NET Core application.
  • Routing: The request is first routed to the appropriate controller and action method based on the URL and HTTP verb. Routing is configured in the Startup class.
  • Middleware Pipeline: The request passes through a series of middleware components configured in the Startup class. Each middleware component can inspect, modify, or handle the request and response.
  • Controller Execution: Once the request is routed, the appropriate controller and action method are invoked to handle the request.
  • Action Execution: The action method performs the necessary processing, such as retrieving data, and prepares a response.

3-Response Generation:

  • View Rendering: If the action method returns a view, the view is rendered to generate HTML.
  • Response Formatting: The response is formatted based on the content negotiation (e.g., JSON, XML) and sent back to the client.
4-Termination:
  • Middleware Cleanup: After the response is sent, any remaining middleware components perform cleanup tasks.
  • Request Completion: The request processing is completed, and the resources associated with the request are released.
Here's a simple example to illustrate the request life cycle in ASP.NET Core:
 
 
In this example:
  • Startup class configures services and middleware.
  • CustomMiddleware is a custom middleware component that intercepts requests before they reach the controller.
  • HomeController contains an action method Index that handles requests to the home page.
  • Request goes through middleware, routing, controller execution, and finally, a response is generated.

 

Request life cycle in Hindi

ASP.NET Core ka request life cycle uss process ko describe karta hai jo hota hai jab ek HTTP request ASP.NET Core application ke liye kiya jata hai. Yeh kuch steps ko follow karta hai:
 
1-Startup: Jab application start hota hai, Startup class execute hoti hai. Yeh services aur middleware ko configure karti hai jo requests ko handle karne ke liye zaroori hote hain.
 
2-Request Handling:
  • HTTP Request: Client ASP.NET Core application ko ek HTTP request bhejta hai.
  • Routing: Request pehle appropriate controller aur action method tak route hota hai URL aur HTTP verb ke base par. Routing Startup class mein configure hota hai.
  • Middleware Pipeline: Request ek series ke middleware components se guzarta hai jo Startup class mein configure kiye gaye hote hain. Har middleware component request aur response ko inspect, modify, ya handle kar sakta hai.
  • Controller Execution: Jab request route ho jata hai, appropriate controller aur action method ko invoke kiya jata hai request ko handle karne ke liye.
  • Action Execution: Action method necessary processing karta hai jaise data retrieve karna aur ek response tayar karna.
3-Response Generation:
  • View Rendering: Agar action method ek view return karta hai, to view HTML generate karne ke liye render hoti hai.
  • Response Formatting: Response content negotiation (e.g., JSON, XML) ke base par format kiya jata hai aur client ko bheja jata hai.

4-Termination:

  • Middleware Cleanup: Response bhejne ke baad, remaining middleware components cleanup tasks perform karte hain.
  • Request Completion: Request processing complete hoti hai aur request ke sath associated resources release ho jate hain.
Yahan ek simple example diya gaya hai jo ASP.NET Core mein request life cycle ko illustrate karta hai:
 
Is example mein:
  • Startup class services aur middleware ko configure karta hai.
  • CustomMiddleware ek custom middleware component hai jo controller tak request pahunchne se pehle intercept karta hai.
  • HomeController mein ek action method Index hai jo home page ke requests ko handle karta hai.
  • Request middleware, routing, controller execution, aur ant mein, ek response generate hota hai.
 
 
 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: