ASP.NET MVC – Simplified
We as a company working on ASP.NET MVC from long time, and considering lot of benefits we decided to move on ASP.NET MVC for all future / upcoming projects. This is certainly great move but difficult to digest to some of our legacy developers.
While asking question, why? most common answer came to me as
MVC is difficult to understand for legacy web developers… Really??
This is not just issue with our guys, even while taking interviews lot of people not really able to explain what is MVC and why it is required.
Is it really complicated? No, it is not! Here is quick guidance.
The ASP.NET MVC is a web application framework developed by Microsoft, which implements the model–view–controller (MVC) pattern.
The Model is the part of the application that handles the logic for the application data.
Often model objects retrieve data (and store data) from a database.
The View is the parts of the application that handles the display of the data.
Most often the views are created from the model data.
The Controller is the part of the application that handles user interaction.
Typically controllers read data from a view, control user input, and send input data to the model.
How MVC Works
- User makes the request for some resource in server (by putting some URL in the browser).
- Request comes to controller first (routing engine is the one who is responsible for deciding which request will be handled by which controller. In this article we won’t talk in depth about this behavior).
- Controller if required talk to model for data.
- Model operates on database (or on some other data sources) and return data (in form of business objects) to controller.
- Controller chooses the appropriate view (like say Customer view which will may contain some html tables, drop downs, textboxes…).
- Controller passes the data (model data retrieved in step 4) to chosen view(in step 5), where data will be populated as per convenience.
- Controller sends back view to the user.
Below is nice video which I found over youtube
There is lot to know, but hope this gives basic idea about ASP.NET MVC