Basics Of ASP.NET MVC

What is ASP.NET MVC?

ASP.NET MVC is basically a framework for developing web applications that are based on Model-View-Controller Pattern, however it is built on top of ASP.NET framework. Hence, you can use features of ASP.NET while working on ASP.NET MVC applications.

Advantage of ASP.NET MVC

  • Separation of Concern: In this, Views(UI)- Controllers(Business logic)- Models (Data Storage) are separate.
  • It supports Test Driven Development(TDD)
  • It supports reusability.
  • It provides better performance than ASP.NET because of the View state.

MVC Pattern

Original name of MVC pattern was Thing-Model-View-Editor when it was launched in 1979, however latter it is simplified as Model-View-Controller. It supports Separation of concern (SoC) by separating UI, Business Logic and Data storage.

  • Model
    These are the classes which describe data.

  • View
    This specifies the UI of application. It helps you describe how your UI is going to be displayed.

  • Controller
    These are the classes, which controls the flow of application, execution of specific business logic.

Asp.Net MVC Life Cycle

It consists of two parts,

  • Application Life Cycle
    It starts at the time application starts running into IIS and ends at the time when application stops running on IIS. This is marked by application start and end events.

  • Request Life Cycle
    Once the Request is made, the application begins with routing. Once routing process is done, then Controller gets initialized; after Controller initialization, the action execution takes place; after action execution, result execution takes place and then it goes to View engine which renders View after which the result execution takes place.