title: Web API Attribute Routes in MVC 5 exception: The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized()
body: <p>On an MVC 5 with Web API I have the following, using only Attribute Routes:</p>
  
  <pre><code>RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  RouteTable.Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" }); // TODO: Check for Apple Icons
  
  RouteTable.Routes.MapMvcAttributeRoutes();
  GlobalConfiguration.Configuration.MapHttpAttributeRoutes();
  AreaRegistration.RegisterAllAreas();
  </code></pre>
  
  <p>In the RouteTable all the MVC routes were created ... But not the API ones ...</p>
  
  <p>I checked the RouteTable.Routes and I see an exception:</p>
  
  <p>The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code.</p>
  
  <blockquote>
    <p>at System.Web.Http.Routing.RouteCollectionRoute.get_SubRoutes()   at
    System.Web.Http.Routing.RouteCollectionRoute.GetEnumerator()   at
    System.Linq.SystemCore_EnumerableDebugView`1.get_Items()</p>
  </blockquote>
  
  <p>For testing this I added only two Web Api actions to the project:</p>
  
  <pre><code>[RoutePrefix("api")]
  public class StatApiController : ApiController {
  
    [Route("stats/notescreateddaily"), HttpGet]
    public IHttpActionResult NotesCreatedDaily() {
      // Some code
    }
  
    [Route("stats/userscreateddaily"), HttpGet]
    public IHttpActionResult UsersCreatedDaily() {
      // Some code
    }
  
  }
  </code></pre>
  
  <p>Am I missing something?</p>
  
  <p>Thank You,
  Miguel</p>