1

We have Sitecore 9.0 update 2 site running on Windows Server 2016. We've added a custom web api controller. We are able to successfully request the custom web api methods on our local environment and the CD environments, but are getting 404 errors on the DEV standalone environment and all CM environments.

Has anyone else experienced/resolved this issue?

2
  • I'm assuming you've added a custom route for your API endpoints via a pipeline processor (before Sitecore.Mvc.Pipelines.Loader.InitializeRoutes)? Have you verified that the necessary configurations are deployed correctly on the CMs. Commented Dec 5, 2019 at 3:57
  • Please share your pipelines patch config and ensure it is deployed across all your environments
    – Abhay Dhar
    Commented Dec 5, 2019 at 9:19

3 Answers 3

0

Add below patch file to allow controller:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <api>
      <services>
        <configuration>
          <allowedControllers>
            <allowedController desc="XXX">XXX,XXX</allowedController>
          </allowedControllers>
        </configuration>
      </services>
    </api>
  </sitecore>
</configuration>
0

Thanks everyone for your replies. I was able to resolve this problem thanks to the answer given here:

WebAPI Controllers not being found in Sitecore 8.2

Per Ben Lipson:

Web API is apparently really aggressive when it caches API Controller types. I was able to fix my issue by doing the following:

  1. stop IIS
  2. kill the w3wps
  3. navigate to C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root and obliterate anything in this folder
0

Just to know:

404 error means that application cann`t find corresponding route to process your request by some reasons.

It is easy to check all registered routes in any place in code by:

var registeredRoutesData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));

(The most common reasons: some config files with route initializers are missing on specific environment or otherwise - environment has its own extra configs that overwrite needed routes).

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