DEV Community

Cover image for What is ASP.Net MVC?
Anshu Verma
Anshu Verma

Posted on • Updated on

What is ASP.Net MVC?

MVC :-
MVC is one of the architectural pattern for implementing user interfaces.
(OR)
MVC is a framework for building web applications using an MVC (Model View Controller) design.

MVC components :-
Model : Model represents the data or shapes the data.
(OR)
Application data and behaviour in terms of its domain and independent of the UI.
(OR)
C # class that represents a table in the SQL server.
(OR)
Basically serves as a data blueprint and can also be used to define the data relations.

Image description

View : The HTML markup that we display to the user.

Image description

Controller : Responsible for handling HTTP request. Get data from database through the model, put them in the view and return the view to the client or the browser.

Image description

There is one more piece to this architecture which is not in the acronym "MVC" but it is nearly always there. It's router. When a request comes in an application, a controller will be selected for handling that request. Selecting the right controller is the responsibility of the router.

Image description

Router : Selects the right controller to handle a request.

Image description

A router based on some rules knows that the request with a URL should be handled by a class. More accurately it should be handled by one of the methods in the class because a class can have many different methods.
In ASP.NET MVC we refer to method of a controller as actions. So it is more accurate to say with, an action in a controller is responsible for handling a request.

Benefit of MVC :-
Better separation of concern : With this architecture each component has distinct responsibility and this results in better separation of concerns and more maintainable application.

Top comments (0)