Life Cycle and Data Annotations Component Model from ASP.NET MVC Tutorial

Before starting the whole ASP.NET MVC tutorial, it is necessary to understand the basic things of MVC.
A Life cycle is a series of steps or events used for handling some types of request or to change an application state. The developers are already familiar with different types of framework lifecycles and this concept is not unique in case of MVC as well.

The ASP.NET webforms platform consists of an intricate page life cycle. Other types of .NET platforms like Windows phone apps have their own application life cycles. One thing which is common for all such kind of platforms regardless the technology is that of understanding the processing of pipeline which can help you to control the features which are available in a better way and thus MVC is not different in such case.

ASP.NET MVC has two life cycles -

  • The Application Life Cycle
  • The Request Life Cycle

The Application Life Cycle: The application life cycle refers to the time at which the application process starts the running IIS until the time it stops. This is mainly driven by the web application starts and end events in the startup file.

The Request Life Cycle: The Request Life Cycle is the sequence of events which occur every time when an HTTP request is handled by our application. The starting point for MVC application begins with Routing. After getting a request by the ASP.NET platform, it then figures out how it should be handled through the URL Routing Module.

Modules are the .NET components which can catch into the application life cycle and add functionality. The Routing module is also responsible for matching the incoming URL to routes so that the developers can define it in the application.

All Routes have an associated route handler and it is the entry point to the MVC framework.

Request -> Routing -> Controller Initialization -> Action Execution -> Result Execution -> View Engine -> Result Execution -> Response

The MVC framework can handle the conversion of the route data into a concrete controller that can handle requests. After the Controller has been created, the next important step is Action Execution. Action Invoker is a component which finds and selects an appropriate Action method to invoke the controller. Now, if you get the View type result, the View Engine will be called and also it is responsible for finding and rendering the view.

If the result is not coming as a View, then the action result will automatically execute on its own way. This Result Execution is what is generating an actual response to the original HTTP request.

Data Annotations:

Another important part while looking for ASP.NET MVC Trainingis Data Annotations. Data Annotations is used for configuring the model class of ASP.NET that will highlight the most important and commonly needed configurations. ASP.NET MVC allows this application to control the same annotations for client-side validations. DataAnnotation attributes override default Code-First conventions.

There are two different types of DataAnnotations Component Model -

  • System.ComponentModel.DataAnnotations
  • System.ComponentModel.DataAnnotations.Schema

Originally published at https://medium.com on September 2, 2019.

I am a diligent and motivated self-worker with 3+ years of experience working in credit review and loan processing within the financial tech industry.