Model . It is a data structure representing an object (usually one). It is designed to read, write and control access to the base object in order to maintain the state of the application.
View . Are the components that are used to display the visual interface to the user, possibly using a model. It can be a simple table or a complex combination on a full web page.
Controller Whether the user logic level of the application sits between views and models. It handles user interaction, loads models, and sends views to the user. It determines which model is sent for viewing depending on user requests.
The general folder structure for an application might look like this.
>> Website >> Controllers >> Models >> Views
In C # MVC, each controller must have a Controller suffix in the name, it must extend the controller class and have a folder with a name prefix (without Controller ) in the views folder. This folder will contain all views related to specific actions on the controller.
Controllers can contain any number of actions defined as public functions. By default, when a result is returned from a controller action, the name of the view must match the name of the action. However, you can also specify the view by name. When loading a view from the controller, you can send the object as a model to the view and create its contents.
Controllers can load any model and are in no way limited.
The Account controller defined below with the Login action. The controller is placed in the AccountController.cs file in the /Controllers folder, and all views of this controller ( Login in this case with the name of the Login.cshtml file) are placed in the /Views/Account folder.
Note. The naming convention must be correct, as names are used between controllers and views to bind data.
public class AccountController : Controller { public ActionResult Login(string returnUrl) { if (User.Identity.IsAuthenticated) { return RedirectToAction("Index","Site"); } return View("Login", new LogOnModel()); } }
will be available through http://www.mysite.com/Account/Login . If the user is authenticated, the controller will be redirected to the main site controller, if the user does not log in, then the Login view will be displayed, which loads the data from the specified LogOnModel .
This really only applies to what is possible. Read some online information about some of the great ScottGu articles that go much deeper and tell you how to use MVC.
ASP.NET MVC Framework Overview
ASP.NET MVC Framework How To - Part 1 // Part 2 // Part 3 // Part 4
Note. These articles are a bit dated because they were written for MVC version 1 in 2007, but the concepts of interaction between models, views, and the controller still apply.