I'm using asp.net core to develop a WebApi.
What is the life-cycle of controller in ASP.NET Core? Does it depends on the web server?
The API lifecycle consists of three primary phases — create, control, and consume. In the create phase, you build and document your API. In the control phase, you apply security policies. And in the consume phase, you publish and monetize APIs.
The ASP.NET Core MVC Request Life Cycle is a sequence of events, stages or components that interact with each other to process an HTTP request and generate a response that goes back to the client. In this article, we will discuss each and every stage of ASP.NET Core MVC Request Life Cycle in detail.
They work similarly in Web API, but controllers in Web API derive from the ApiController class instead of Controller class. The first major difference you will notice is that actions on Web API controllers do not return views, they return data. ApiControllers are specialized in returning data.
In ASP.NET Web API, a controller is a class that handles HTTP requests. The public methods of the controller are called action methods or simply actions. When the Web API framework receives a request, it routes the request to an action. To determine which action to invoke, the framework uses a routing table.
Usually an instance of a controller is created per request and if you use dependency injection, all associated services are created for that request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With