Wednesday 20 March 2013

MVC

MVC - Model View Controller

Controller - main function place that controls everything
Model - Connected to database tables, objects
View - reads data from user, play with Model, and displays

Name conventions:
HomeController.cs controls Views/Home.
Function f1() { return View(); } in HomeController.cs returns view, Views/Home/f1.cshtml

Instead of mapping incoming URLs to files, they instead map URLs to methods on classes.

The url ~/first/second/third means {controller}/{action}/{parameters}. It means, FirstController.cs has a function second() with a parameter third, and if the function returns View(), it will show Views\First\Second.cshtml.

visual studio 2010 View folder has the following structure:

\Views\[ControllerName]\[ActionName]