Attribute Routing in ASP.NET Web API 2

SOS Childrensvillages asked on May 18, 2018 11:56

Hi,
we are trying to use attribute routing so we can have multiple post or get methods on the same controller. I tried adding GlobalConfiguration.Configuration.MapHttpAttributeRoutes() as per here but I end up getting my CMS 404 page. I added it to my CustomWebAPIModule's OnInit method after the call to MapHttpRoute("Default", "custom/{controller}/{id}", new { id = RouteParameter.Optional }); that's described in the documentation.

Is there a way to use attribute routing in Kentico? Convention routing keeps returning the multiple method error, though I added a mapping like so: customapi/{controller}/{action}/{id}.

Thanks in advance

Using K11, portal template model

Recent Answers


profound Team answered on October 4, 2018 13:37

We have managed to get attribute routing working happily from a module with K11.

Its not very well documented, but the steps are:

  1. Follow Kentico's documentation to start with
  2. Override global exception handling
  3. add /customapi to System \ URLs and SEO \ Excluded URLs

A good guide (credit to Sean Wright) is here:

https://www.wiredviews.com/blog/april-2016/integrating-kentico-cms-with-asp-net-web-api-2

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.