c# - Routing to a hard-coded Controller -


this route mapping doesn't work:

configuration.routes.maphttproute(     "environmenttargetsview",     "api/environmenttargetsview/{id}/{userguid}",     new     {      id = routeparameter.optional,      userguid = routeparameter.optional,     }); 

i error: "no route providing controller name found match request uri"

however, route mapping work:

configuration.routes.maphttproute(     "environmenttargetsview", "api/{controller}/{id}/{userguid}",     new     {      controller = "environmenttargetsview",      id = routeparameter.optional,      userguid = routeparameter.optional,     }); 

i curious why , have surfed answers on here, can't figure out. want hard-code value because specific route want api take. worry having tokenised in routetemplate can not use route similar pattern.

it's because specified:

controller = "environmenttargetsview" 

in second code block. if add first code block it'll work , still have hard coded value.

you add like:

[route("/api/environmenttargetsview/{id}/{userguid}] public void get(int id, guid userguid) { } 

to controller methods.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -