ASP.NET MVC - Model View Controller


 ASP.NET MVC 5 is a web framework based on Model-View-Controller (MVC) architecture.

Developers can build dynamic web applications using the ASP.NET MVC framework that enables a clean separation of concerns, fast development, and TDD friendly.

MVC

*MVC stands for Model, View, and Controller.

MVC separates an application into three components - Model, View, and Controller.

*Model :

The model represents the shape of the data. A class in C# is used to describe a model.
Model objects store data retrieved from the database.

*View :

View in MVC is a user interface. View display model data to the user and also enables them to modify them.
View in ASP.NET MVC is HTML, CSS, and some special syntax (Razor syntax) that makes it easy to communicate with the model and the controller.

The view is a User Interface that displays data and handles user interaction.
The views folder contains a separate folder for each controller.
ASP.NET MVC supports Razor view engine in addition to traditional .aspx engine.
Razor view files has .cshtml or .vbhtml extension.

ASP.NET MVC

Readonly-{ASP.NET MVC views are stored in the Views folder.
Different action methods of a single controller class can render different views,
so the Views folder contains a separate folder for each controller with the same name as the controller,
in order to accommodate multiple views.
For example, views, which will be rendered from any of the action methods of HomeController,
resides in the Views > Home folder. In the same way, views that will be rendered from Student Controller
will reside in Views > Student folder as shown below.}

Razor View Engine
Readonly-{Microsoft introduced the Razor view engine and packaged it with MVC 3.
You can write a mix of HTML tags and server-side code in razor view.
Razor uses @ character for server-side code instead of traditional <% %>.
You can use C# or Visual Basic syntax to write server-side code inside razor view.
Razor view engine maximizes the speed of writing code by minimizing the number of characters and keystrokes required when writing a view.
Razor views files have .cshtml or vbhtml extension.}

*Controller :

The controller handles the user request.
Typically, the user uses the view and raises an HTTP request, which will be handled by the controller.
The controller processes the request and returns the appropriate view as a response.

A Controller handles incomming URL requests.
MVC routing sends a request to the appropriate controller and action method based on URL and configured Routes.
All the public methods in the Controller class are called Action methods.
A Controller class must be derived from System.Web.MVC.Controller class.
A Controller class name must end with "Controller".
Every controller in MVC must be derived from this abstract Controller class.
This base Controller class contains helper methods that can be used for various purposes.

If you found this article useful, share it.*

ASP.NET MVC Question Answer Link

FACEBOOK

Watches (tiptopstores.blogspot.com)

Nature's Routes (naturesroutes.blogspot.com)

No comments:

Post a Comment