In ASP. NET learning notes, when will the parameters in HTML helper be Routing Parameters and query strings ?, Helperquery
When will the parameters in HTML helper be Routing Parameters and query strings? @ Html. actionLink ("Edit", "Edit", new {idnumber = item. orderTypeID}) in the preceding html helper, the third parameter is routeValues. If the third parameter does not appear in the route file RouteConfig in App_Start. in cs (url: "{controller}/{action}/{id}/{actionid}"), the third parameter will appear in the url as query string, that is, http: // XXX/ordertypes/Edit? Idnumber = 1. It should be noted that routeValue is not included in the url routing definition, and none will appear in the url as query string. @ Html. actionLink ("Edit", "Edit", new {id = item. orderTypeID}) But if the third parameter appears in the url: "{controller}/{action}/{id}/{actionid}" definition, it will appear in the url as a route parameter, that is, http: // XXX/ordertypes/Edit/1 (the default route is the edit Method in the ordertypes controller, and the parameter id = 1, the routing parameters are written to the url in the preceding two forms and passed to the controller. However, you must ensure that the parameter name of html helper in views must be consistent with the parameter name in the corresponding actionMethod In the controller, in this way, the data in the view can be correctly transmitted to the controller.