ASP. net mvc learning notes on the first day, mvc learning notes

Source: Internet
Author: User

ASP. net mvc learning notes on the first day, mvc learning notes
MVC: Mode, View, Controller)

When the server receives a Request, the Routing defines the Controller to be called and the Controller action to be called. The Controller is responsible for returning results. It can use a model to complete the work, and finally return a view engine, which searches for the appropriate view ). View results are returned in the corresponding Response. Define route: the default route is defined in the RegisterRoutes method. Let's look at an example URL of MVC: http://localhost:Home/Index/demo In this URL, the Controller value is Home, the action value is Index, and the id value is demo. Public static void RegisterRoutes (RouteCollection routes) {routes. ignoreRoute ("{resource }. axd/{* pathInfo} "); routes. mapRoute (name: "Default", url: "{controller}/{action}/{id}", defaults: new {controller = "Home", action = "Index ", id = UrlParameter. optional});} Add a route: cause: for example, modify a route so that only the action with a link is used. Define Home as the default controller and add additional items to the link, you can also use multiple parameters. Route constraints: You can specify constraints when ing routes. In this way, you can only use the URL defined by the constraint.  

Related Article

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.