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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -