Do the parameter names in ASP.NET MVC routes need to match those in their corresp开发者_开发问答onding actions, and if so, why?
Yes, bacause of convention (over configuration). It's simplier and faster do develop application in that way: that's the power of ASP.NET MVC.
Indeed. The RouteData collection's "Values" dictionary will be scanned for the key/value pair whose name matches the parameter name.
In the following action method the "month" parameter would be automatically populated according to the {month} portion of the incoming URL route:
public ActionResult Index(string month) {
if( month == "1" )
//Happy New Year!
}
1) Yes. 2) How else would they match? The name is all you have, in both cases.
No, not when you create your own defaultmodelbinder and/or controlleractioninvoker
精彩评论