I followed the steps below to define custom ASP.NET MVC routes.

Created a custom processor for the initialize pipeline and defined custom route in the Process method similar to the following:

public class RegisterCustomRoute
  public virtual void Process(PipelineArgs args)
    RouteTable.Routes.MapRoute("CustomRoute", "some/route/{controller}/{action}/{id}");

Added this processor to the initialize pipeline right before the Sitecore InitializeRoutes processor.

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
                    <processor type="MyNamespace.RegisterCustomRoute, MyAssembly" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />

I placed this patch file into a subfolder of the /App_Config/Include/Z_CustomConfigs directory.

The route has been registered successfully in the RouteTable however whenever i tried to access the url http://[domain]/some/route/[controller]/[action]/1 in browser, I never get this url matched in Sitecore application and it always redirected to 404 page with invalid url message.


I am having below code for the controller

public class ProductFilterController : SitecoreController
     // GET: Product
     public ActionResult Search(int id)
         return View();

And trying to access it using the url


However, when i added /some/route/ in IgnoreUrlPrefixes config setting, the route resolved successfully but in this way, i would not get the Sitecore context. Thus, not much beneficial to resolve the problem statement.

References: https://kb.sitecore.net/articles/700677

  • We would need to see the actual code and actual configuration, to be able to help you. – Mark Cassidy Jan 31 at 10:26
  • I tried the exact same code and configuration but it never worked. – Arvind Gehlot Jan 31 at 10:30
  • But your controller code? – Mark Cassidy Jan 31 at 10:33
  • 1
    Don't inherit SitecoreController. It isn't intended for this purpose. It would be either ServicesApiController or just ApiController. And don't modify global.asax either. – Mark Cassidy Jan 31 at 12:05
  • 1
    In case of ServicesApiController (ASP.NET WebAPI) there is even no need of overriding the processor (which is for MVC routing). See the following page for details: doc.sitecore.net/sitecore_experience_platform/developing/… – Serhii Shushliapin Jan 31 at 12:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.