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.