Model: data and business rules
View: Output and representation are displayed.
Controller: converts user input into data that can be processed by the model.
Access localhost/home/index. aspx,
Actual mechanism: Action index in homecontrol. CS;
Return Mechanism: Return views/controller/index. aspx
Summary: When requesting aspx, it is the action method under the request control class.
When views are returned, the action. aspx of the control class under the view directory is returned.
Getting startedArticle
C1http: // www.cnblogs.com/qleelulu/archive/2008/09/30/1302462.html
C2http: // www.cnblogs.com/qleelulu/archive/2008/10/03/1303521.html
C3http: // www.cnblogs.com/qleelulu/archive/2008/10/03/1303612.html
Official Entry Example of MVC
Http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/intro-to-aspnet-mvc-3
// Get:/helloworld/ # Region Add action Method for controller class /* Default MVC ing format of MVC */ Public String Index () // Call method: controller prefix/Index { Return " This is <B> default </B> action " ;} // Public String welcome () // Call method: controller prefix/welcome // { // Return "this is welcome action "; // } // Http: // localhost : 7391/helloworld/welcome? Name = Scott & numtime = 1 // The URL parameter name must be the same as the parameter name. Public String Welcome ( String Name, Int Numtime) // Function Overloading is not allowed in control, { Return " Hello " + Name + " Numtime is: " + Numtime. tostring ();} # Endregion
△ Controller parses the URL and parameters and writes the results to viewdata (key-value pairs), viewbag, and view to generate the result page.
Public class helloworldcontroller: controller { Public actionresult welcome ( string name, int numtime) {viewdata [ " message " ] = " Hello " + name; viewdata [ " numtime " ] = numtime; return View ();}}
Welcome. aspx
< H2 > Welcome </ H2 > < Ul > <% For ( Int I = 0 ; I <= Convert. toint32 (viewdata [ " Numtime " ]); I ++ ){ %> < Li > <% = Viewdata [ " Message " ]. Tostring () %> </ Li > <% } %> </ Ul >