What is MVC in .NET ?
MVC is a web application framework developed by Microsoft. Lets understand how it works before moving on lets see what it means by MVC.
MVC is a web application framework developed by Microsoft. Lets understand how it works before moving on lets see what it means by MVC.
Model-View-Controller : M Stands for Model , V Stands for View and C Stands for Controller.
Lets understand it with examples and pictures , I have used C# to display code snippets
What is Model ?
Models are blueprint of our tables in database. They reflect that how our table looks like. Lets experience it with an example. Suppose we have a table named Cinema that looks like this
So to communicate with database we use same replica of that table that looks like this
2. What is View ?
View is front end , view is user end , view is the screen that users looks. Currently you are on medium then this is the view.
View is basically your HTML,CSS in .NET we use cshtml pages or we can call them Razor Pages.
Lets look at an example this is an example of view
On the other hand their would be cshtml behind this.
3.What is Controller ?
Controller is basically responsible for interaction between View and Model. Every request (Get,Put,Post,Delete,Patch) comes at controller then controller receives data through model and sends it back to the view .
4. How these components communicates with each other ?
Whenever user requests information through URL via browser then request comes at controller and controller then receives information through model and sends it back to view. Look at example how architecture looks like.
If you like my work you can help me in growing through following ways