ASP. NET MVC

Source: Internet
Author: User

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  > 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.