It’s been a while since I last updated this blog. Today I want to talk about a lesson learned, a fact that maybe known by many Sitecore developers already but I’ve only recently realized.
I’ve recently worked on a project to create a new component. The project I work on is on Sitecore 8.x and we want to use AJAX call for this new component. As always, I am a lazy developer, so I was thinking to take the shortcut – make use of Sitecore pre-defined route api/sitecore/{controller}/{action} instead of registering our own route. We created a small POC on our local and it works – perfect – until we deployed the new feature to UAT.

The deployed new feature doesn’t work on UAT, or more strictly speaking, not working on CD servers. The AJAX call returns 404 not found. It is however working as expected on CM server. After some investigation , I realised the route we are using api/sitecore/{controller}/{action} is intended for SPEAK framework. So now it makes sense why it can only use in CM server. SPEAK is for Sitecore client use only so it doesn’t work on CDs. And when we tested it on our local, because we don’t have the CM/CDs setup so we didn’t find out.
Sitecore register this route in Sitecore.Mvc.Pipelines.Initialize.InitializeCommandRoute pipeline. And there is way to enable to it to works on CDs by register the route on CD servers through Global.asax. However after reading few articles I think actually it’s not a good idea to use api/sitecore/{controller}/{action} for many reasons
- It has deprecated so we will have issue with this route when we upgrade anyway.
- To avoid clashes with Sitecore API it is good practice to have your own route.
Details about how to register your own route, please refer to Sitecore documentation here.










