We have a multi-site environment.

In one of the module, we are calling the same controller/action from all the sites. Perhaps, the same Javascript file which calls this controller/action is included in all the sites. But, I'm able to get the response from Site1 but, Site2 is redirecting the request to 404.

http://site1/api/mic/MyController/myaction -- Is working

http://site2/api/mic/MyController/myaction -- Is not working

Recently we have upgraded from Sitecore 8.0.4 to Sitecore 9.0.2, In Sitecore 8 instance both are working.

Just to debug the issue,

  • I had deleted the Site.Config forSite2` and tested, it is able to get the proper response. Not sure what's happening here. Attached the site config below. enter image description here
  • Also noticed that from site2 I'm not able to hit any of the controller/action.

I suspect that, Api routing is not working. When we include Site2's site.config, Sitecore routing is taking place, not the mvc routing.

Your help and prompt response are appreciated.

UPDATE 1 : I had noticed that, in Site definition, when the start item is pointing to Site2's home item, i'm getting error. It works with any other item in the content tree. Is there any problem with Sitecore item? or did i missed any configuration?


I noticed that, under Site2 Sitecore node, we have wild card items. Something like this


This is matching http://site2/api/mic/MyController/myaction request.

Now I'm sure that, when we call the api it is matching the Sitecore Content tree items and then it is redirecting to 404 page.

Now the question is how to tell Sitecore to take mvc routing as routing for this request?

1 Answer 1


It needs to create custom routing for calling a controller action method for multisite. Steps are as below:

Step 1) Add App_start folder in the Foundation Layer Project. Add a class file in this folder e.g. RegisterWebApiRoutes.cs, use the below code in this class file.

public void Process(PipelineArgs args)
            RouteTable.Routes.MapRoute("API", "api/sitecore/{controller}/{action}/{id}",
                new { controller = "controllerName", id = UrlParameter.Optional },
                new[] { "dllName.Controllers" } //e.g. Sitecore.Foundation.Accounts.Controllers

Step 2) created the config file of that layer, register the routing e.g. Sitecore.Foundation.Accounts.config use below code for register routing:

        <processor type="Sitecore.Foundation.Accounts.App_Start.RegisterWebApiRoutes,Sitecore.Foundation.Accounts" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" resolve="true" />
    </pipelines>  </sitecore>

I hope it will work for you because it worked for me.

  • Its already there in common solution. Also, i have added the above config for this site aswell. Not working. As i told, Sitecore 8 instance working without any issues.
    – PaRsH
    Jun 3, 2019 at 13:27
  • Please check the Sitecore.Mvc.dll version for sitecore 9.0.2. Jun 3, 2019 at 13:52
  • Its Version and its Sitecore 9.0.2/
    – PaRsH
    Jun 3, 2019 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.