1.

Explain about ASP.NET MVC life cycle.

Answer»

A Life cycle refers to a sequence of events or steps used for handling some kind of request or modifying the state of an application.

ASP.NET MVC has two life cycles. They are:

  • The Application Life Cycle: The ASP.NET application life cycle begins when a request is raised by a user. It refers to the time when the application process starts running IIS(Internet Information Services) till the time it ends. This is identified as the start and end events of an application in the startup file of your application. On Application Start, the application_start() method will be executed by the webserver. All global variables will be set to default values using this method. On the Application End, the application_end() method will be executed and this will be the final part of the application. The application will be UNLOADED from the memory in this part.
  • The Request Life Cycle: It refers to the series of events that will be executed each time when an HTTP request has been handled by the application. Routing is considered to be an entry point for each MVC application. After the request is received by the ASP.NET platform, it finds out how the request has to be handled with the help of the URL Routing Module. Modules are the components of a .NET that can be attached to the application life cycle. The routing module is helpful in matching the incoming URL(Uniform Resource Locator) to the routes that are defined in our application. All routes will be having a route handler associated with them and this route handler is considered to be an entry point to the MVC FRAMEWORK.

The route data will be converted by the MVC framework into a concrete controller that is capable of handling the requests. The major task after the creation of a controller is Action Execution. An action invoker component will find and select the suitable Action method for invoking the controller.

The next stage after the PREPARATION of the action result is Result Execution. MVC will separate result DECLARATION from result execution. If the result is of view, then it will find and render our view by CALLING the View Engine. If the result is not a view type, the action result will be executed on its own. This Result Execution will generate an original response to the actual HTTP request.



Discussion

No Comment Found