More in this section

Forums / Developing with Sitefinity / Web API 2 Attribute Routing

Web API 2 Attribute Routing

2 posts, 1 answered
  1. Chris
    Chris avatar
    0 posts
    08 Apr 2015
    17 Jan
    Link to this post

    I'm trying to use an Web Api Controller that has Route Attributes, but I'm unable to get it working.



    when the site is initializing causes it to stay on the loading page forever. I don't see any errors being thrown, so it's hard to determine where it's going wrong.

    Has anyone been able to get Route Attributes working?

  2. Chris
    Chris avatar
    0 posts
    08 Apr 2015
    17 Jan in reply to Chris
    Link to this post

    In case anyone else runs into this problem, here's the solution I found:

    I noticed that though there were no errors being logged, the loading screen was making a failed request to


    The error message from the request was this:

        <Message>An error has occurred.</Message>
            The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code.
        at System.Web.Http.Routing.RouteCollectionRoute.get_SubRoutes() at System.Web.Http.Routing.RouteCollectionRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request) at System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase httpContext)


    After the code registering the Routes, I added the line 


    and the site loaded and the Route Attributes were working again.

2 posts, 1 answered