Web API routes failing v8.1.4

Adam Steffes asked on September 30, 2014 17:16

I have a Kentico project that was recently upgraded to version 8.1.4 from some version < 8.1.

A previously working Web API route and controller is no longer functioning, and I'm struggling to understand what else I can try to get it to work.

Our route is defined as follows:

config.Routes.MapHttpRoute("Api", "api/{controller}/{action}/{id}", new { id = RouteParameter.Optional }

This is how our route is and was defined. This code is called from the MCS_MVCModule class during initialization as follows:


Our controller is defined as: public class CommentsController : ApiController

Our action is: public CommentResponse GetComments(int boardID)

Couple of troubleshooting steps we've noticed and addressed: -Added the /api/ path to Kentico's "ignore urls" list -Verified that the route configuration is being hit -We did notice that the upgrade eliminated our WebApiConfig.Register() method's contents. We added back in the route above. - We noticed that the upgrade process ignored our custom-named solution file, and instead created a new solution file without the web API components. We've verified that they're back in place

Really looking for any good alternatives here. Please let me know if you have any suggestions.

Recent Answers

Jakub Kadlubiec answered on October 2, 2014 15:58 (last edited on October 2, 2014 15:58)

Hi Adam,

we use WebWpi in Kentico 8.1 as well and we noticed poor performance at application start caused by WebApi and we had to customize it a little in order to make it perform better. To be more specific, when application starts, WebApi browses through all assemblies and tries to find classes deriving from ApiController. As our code base is fairly large, this lookup took too long and we needed to replace the default WebApi IHttpControllerTypeResolver with our implementation which looks only for explicitly registered controllers.

You have two options how to make your API work:

Option 1: Register all of your controllers with the RegisterApiController assembly attribute.

[assembly: RegisterApiController(typeof(LiveTileController))]

namespace CMS.ApplicationDashboard.ApiControllers
    internal sealed class LiveTileController : ApiController


You will need to reference CMS.WebApi assembly to do that.

Option 2: Use newer version of WebApi than we use - that would be version 2 (assembly 5.2.2)

I apologize for the inconvenience this issue caused you. We are thinking how to improve this in Kentico 8.2. One of the solutions we are looking at, is to require registration only for our libraries and always go through all classes in customer's libraries including CMSApp_MVC.

2 votesVote for this answer Mark as a Correct answer

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