MVC Controller Brief Introduction (internal use)

Source: Internet
Author: User

The controller (Ccontroller) in the MVC pattern primarily corresponds to the user's input, and the model is modified as appropriate, and the input data (View) should be considered the soul element of the MVC3 core element.

The traditional webform is that the user is using the HTML page on the server disk of the browser and MVC is different, MVC is the way to get the appropriate action method (action) and provide parameters for the method, and then the method determines what view to use

and renders for the view.

Simply create a controller

  public class Homecontroller:controller    {        ////        GET:/home/public        string Index ()        {            return ' This Index ";        }        public string Detail (string name)        {            return ' this Detail ' + name;        }        public string Create ()        {            return ' this create ';        }    }

We can see that this is a very concise approach that only inherits the base class of the controller.

Where the index method is the underlying method of the detail browser trigger event,

We enter in the browser

Http://localhost:57950/Home

The mechanism for routing through MVC is then matched to the index method

Http://localhost:57950/Home/Detail

The same principle will match the corresponding detail method.

Http://localhost:57950/Home/Detail/5

If the connection contains parameters, the modification method can also accept the parameters

There's another way to accept it.

Http://localhost:57950/Home/Detail?name=MVC

Here's a brief talk about how the controller works and how to access it.

  

MVC Controller Brief Introduction (internal use)

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.