with routing defined in routeconfig.cs
routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "durandal", action = "index", id = urlparameter.optional } ); i expected http://localhost:50441/api/induction/getintro/4108 parse
controller = inductioncontroller action = "getintro" id = 4108 and call getintro method of class
using system.web.http; namespace mymvcapp.controllers { public class inductioncontroller : apicontroller { public object getintro(int inductionid) { //simplified brevity return new { title = "foo", text = "some introductory blather" }; } } } but doesn't. 404 not found, , burning question why.
most samples seem use maphttproute instead of maproute, maproute being extension method wraps maphttproute.
i confused existence of routeconfig.cs defines routes. works this:
- webapi routes configured
webapiconfig.cs - mvc routes configured
routeconfig.cs - you both because it's mvc project support webapi.
in project route defined in webapiconfig.cs api\{controller}\{id} , preceding route api\{controller}\{action}\{id} resolved problem.
the template generated crud methods worked because match api\{controller}\{id}
Comments
Post a Comment