asp.net mvc - Routing, hitting wrong action -
i have 2 actions, , whenever explicitly call second one, first 1 still gets called. need able write in mysite.com/api/awesome/getsomeexamples, without triggering getallclasses
public class awesomecontroller : controller { public ienumerable<myclass> getallclasses() { //...some stuff } public ienumerable<string> getsomeexamples() { //...some stuff } //... have more actions take in 1 parameter }
my routing such, not working
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "actionapi", url: "api/{controller}/{action}/{id}", defaults: new { id = urlparameter.optional } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); }
error getting: multiple actions found match request
you using web api.
the difference normal mvc actions web api looks @ http verb determine action call. in case have 2 methods start get
however, should trigger error: multiple actions found match request...
, shouldn't call both actions.
the url need is:
mysite.com/api/awesome/
from there, web api call method starts get
. need remove other method , put in different controller. web api supposes have 1 action per http verb
Comments
Post a Comment