asp.net web api - Multiple GET actions in webApi Controller -
i know question have been asked many times before. have different problem.
single controller multiple methods in asp.net web api
i have followed steps provided in post on above link, api link in format of api/servicename/controller.
and routes given in post api/controller format. 1 please in getting sorted out. replced routes exact name of service of no use.
i got solution, instead of writing routes api/controller/action, wrote in way given below. got code block link http://lonetechie.com/2013/03/04/fixing-multiple-actions-were-found-that-match-the-request-aspnet-webapi/ points link have given in original post.
config.routes.maphttproute("defaultapiwithaction", "{controller}/{action}", new { action = "get" }); config.routes.maphttproute("defaultapi", "{controller}/{id}", new { id = routeparameter.optional }, new { id = @"\d+" }); config.routes.maphttproute("defaultapiget", "{controller}", new { action = "get" }, new { httpmethod = new httpmethodconstraint(httpmethod.get) }); config.routes.maphttproute("defaultapipost", "{controller}", new { action = "post" }, new { httpmethod = new httpmethodconstraint(httpmethod.post) }); config.routes.maphttproute("defaultapiput", "{controller}", new { action = "put" }, new { httpmethod = new httpmethodconstraint(httpmethod.put) }); config.routes.maphttproute("defaultapidelete", "{controller}", new { action = "delete" }, new { httpmethod = new httpmethodconstraint(httpmethod.delete) });
Comments
Post a Comment