title: Web API routing in Sitecore 8.2
body: <p>I migrated a sitecore 7.2 application to sitecore 8.2 using the express migration tool. After the migration Web API routing stopped working. I'm using below given method to map the routing</p>
  
  <pre><code> [UsedImplicitly]
          public class ConfigRegister
          {
              /// &lt;summary&gt;
              /// Startup method to bind all configurations for site core pipeline.
              /// &lt;/summary&gt;
              /// &lt;param name="args"&gt;&lt;/param&gt;
              public virtual void Process(PipelineArgs args)
              { RouteConfig.RegisterRoutes(RouteTable.Routes);
       }
          }
  </code></pre>
  
  <p>Then registering it using following code snippet</p>
  
  <pre><code>public static void Register(HttpConfiguration config)
          {
           config.MapHttpAttributeRoutes();
              config.Routes.MapHttpRoute(
                  name: "ControllersApi",
                  routeTemplate: "WebApi/CustomerPortal/{controller}/{action}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
          }
  </code></pre>
  
  <p>I'm getting error A route named 'MS_attributerouteWebApi' is already in the route collection. Route names must be unique.
  Parameter name: name. </p>
  
  <p>But when I comment the line </p>
  
  <pre><code>config.MapHttpAttributeRoutes();
  </code></pre>
  
  <p>I'm getting error 
  {"Message":"An error has occurred.","ExceptionMessage":"The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code.","ExceptionType":"System.InvalidOperationException","StackTrace":"   at System.Web.Http.Routing.RouteCollectionRoute.get_SubRoutes()\r\n   at System.Web.Http.Routing.RouteCollectionRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request)\r\n   at System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase httpContext)"}</p>
  
  <p>Your help to solve this issue is highly appreciated</p>