Parameters with ASP.NET MVC routes for same number of params -
route matching requires parameter name match. below match action single parameter fileid. however, not match action single parameter of different name. therefore, have route actions take single parameter sessionid.
the second route doesn't work, first 1 declared. confuses me: understand matching stops first match found, if doesn't match first parameter name surely match has not been found , matching should continue? doesn't.
config.routes.maphttproute( name: "downloadurl", routetemplate: "api/{controller}/{action}/{fileid}" ); config.routes.maphttproute( name: "queue", routetemplate: "api/{controller}/{action}/{sessionid}" );
i use single route , call parameters a, b, c... naming them ordinal position.
config.routes.maphttproute( name: "downloadurl", routetemplate: "api/{controller}/{action}/{a}" );
but that's horrible code assume not understand routing enough. how express both these routes?
experimentation has revealed explicit naming combined defaults can sort out:
config.routes.maphttproute( name: "authenticate", routetemplate: "api/{controller}/authenticate/{email}/{password}", defaults: new { action = "authenticate" } ); config.routes.maphttproute( name: "uploadedbytes", routetemplate: "api/{controller}/uploadedbytes/{sessiondid}/{fileid}", defaults: new { action = "uploadedbytes" } );
Comments
Post a Comment