ASP.NET MVC Framework

By   Calendar icon Jan 14, 2017   Level 1 icon


ASP.NET MVC Framework



MVC Architecture

MVC is an architectural pattern dividing a Web application into three parts: the model, the view and the controller.

  • The model manages the data (access to databases, files, blob storages...)
  • the view is responsible for representing the data provided by the model in a certain form
  • the controller manages request from users and provides a response using the model and the view

What are the advantages of this architecture?
The application respecting the MVC architecture is modular and it avoids completely change the application if the developer just needs to display data in a different form or modify data access.

Model View Controller

After creating an ASP MVC web application with Visual Studio, you can see the presence of the Views, Controllers and Models directories.
The Views directory contains aspx, cshtml, and vbhtml files, depending on the language content.
Controllers and Models directories contain cs or vb files.
A Model or Controller are C# or VB.NET classes.
A controller contains methods ending in return View(); called controller action.

For example, if you declared a controller named CarsController containing the controller action index(), you can trigger this action by entering the following URL in the address bar of the browser: http://localhost/Cars/Index

A view is a vbhtml, cshtml or aspx file. The views are script-based template system that generate HTML pages containing JavaScript.