asp.net mvc - "ExceptionMessage": "Multiple actions were found that match the request: -
hi found many helpful link solve nothing working me :(. can 1 @ going wrong?
controller :
[actionname("savebook")] [httppost] public httpresponsemessage postsavebook([frombody]book product) { return add(product); } [actionname("savemobile")] [httppost] public httpresponsemessage postsavemobile([frombody]mobile product) { return add(product); }
webapirouteconfig.
config.routes.maphttproute( name: "controlleronly", routetemplate: "api/{controller}" ); // controller id // handle routes `/api/vtrouting/1` config.routes.maphttproute( name: "controllerandid", routetemplate: "api/{controller}/{id}", defaults: null, constraints: new { id = @"^\d+$" } // integers ); // controllers actions // handle routes `/api/vtrouting/route` config.routes.maphttproute( name: "controllerandaction", routetemplate: "api/{controller}/{action}" );
error :
**
"exceptionmessage": "multiple actions found match request:
**
the first route have registered restful style route, doesn't include {action}
segment.
as routes evaluated in same order registered, whenever send post request, controller name taken url, , then, action selector action name starts post
. in case there 2 actions fulfill condition: postsavebook
, postsavemobile
.
if first registered route "controllerandaction"
one, action taken url , action selector correctly choose desired action.
if want use restful style, you'd have use attribute routing break ambiguity.
Comments
Post a Comment