I am on Sitecore 9.1.

I have read this question and this other one; my configuration is as follows.

In order to execute my code on startup, I hijack the initialize pipeline:

    <processor patch:after="processor[@type='Sitecore.Pipelines.Loader.EnsureAnonymousUsers, Sitecore.Kernel']"
      type="MyProject.Pipelines.RegisterHttpRoutes.WebApiConfig, BlueRubicon.Pipelines" />

My Global.asax is the default one:

<%@Application Language='C#' Inherits="Sitecore.Web.Application" %>

And I have no Global.asax.cs.

This is the WebApiConfig class:

public class WebApiConfig
    public void Process(PipelineArgs args)

    public void Register(HttpConfiguration config)
        config.Routes.MapHttpRoute("FileUploadApi", "api/FileUpload/{id}",
            new { controller = "FileUpload", id = RouteParameter.Optional });

        config.Routes.MapHttpRoute("CareersApi", "api/careersapi/{action}/{id}",
            new { controller = "CareersApi", id = RouteParameter.Optional });

        config.Routes.MapHttpRoute("Inspiration", "api/inspiration/{action}/{id}",
            new { controller = "Inspiration", id = RouteParameter.Optional });

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


Why am I still getting the The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code. error?


Are you just trying to register API routes? Its way easier than that.


public class InitializeRoutes
    public virtual void Process(PipelineArgs args)
        // Registration
            + Constants.ApiVersion
            + "/membership",
            new { controller = "RegistrationApi", action = "Create" },
            new { httpMethod = new HttpMethodConstraint("POST") }


    <processor type="YourApp.Pipelines.Initialize.InitializeRoutes, YourApp" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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