title: WebApiConfig.Register Clears routes defined by RouteConfig.RegisterRoutes apon deployment
body: <p>I'm on struggle street here, When I try to add API controllers it seems to destroy all my MVC base routes and area routes.</p>
  
  <p>On my application start I call</p>
  
  <pre><code>protected void Application_Start()
  {
      AreaRegistration.RegisterAllAreas();
  
      WebApiConfig.Register(GlobalConfiguration.Configuration);
      //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
      RouteConfig.RegisterRoutes(RouteTable.Routes);
      Util.RazorDebuggingSetup();
      BundleConfig.RegisterBundles(BundleTable.Bundles); 
  }
  
  using System.Web.Mvc;
  </code></pre>
  
  <p>An example of an area config:</p>
  
  <pre><code>namespace **.Areas.Console
  {
      public class ConsoleRegistration : AreaRegistration
      {
          public override string AreaName
          {
              get
              {
                  return "Console";
              }
          }
  
          public override void RegisterArea(AreaRegistrationContext context)
          {
              context.MapRoute(
                  "Console_default",
                  "Console/Index",
                  new { controller = "base", action = "Index"}
              );
  
              context.MapRoute(
                  "Console_default2",
                  "Console/{controller}/{action}/{id}",
                  new { action = "Index", id = UrlParameter.Optional }
              );
          }
      }
  }
  </code></pre>
  
  <p>My WebApiConfig Class</p>
  
  <pre><code>using System.Web.Http;
  
  namespace **.Modules.MVC
  {
      public static class WebApiConfig
      {
          public static void Register(HttpConfiguration configuration)
          {
              configuration.Routes.MapHttpRoute(
                  "API Default", 
                  "api/{controller}/{id}",
                  new
                  {
                      id = RouteParameter.Optional
                  }
              );
          }
      }
  }
  </code></pre>
  
  <p>And the route class</p>
  
  <pre><code>using System.Web.Mvc;
  using System.Web.Routing;
  
  namespace **.Modules
  {
      public class RouteConfig
      {
          public static void RegisterRoutes(RouteCollection routes)
          {
              routes.MapRoute(
                  "ErrorHandler",
                  "Error/{action}/{id}",
                  new { controller = "Error", action = "Generic" , id = UrlParameter.Optional }
              );
  
              // Ignore old Friendly URLS.
              // These should be removed.
              routes.IgnoreRoute("Account/Login");
              routes.IgnoreRoute("");
              routes.IgnoreRoute("Website/{*pathInfo}");
              routes.IgnoreRoute("Pages/{*pathInfo}");
  
              routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });
              routes.IgnoreRoute("{*allasp}",  new { allasp = @".*\.asp(/.*)?" });
              routes.IgnoreRoute("{*allhtml}", new { allhtml = @".*\.html(/.*)?" });
              routes.IgnoreRoute("{*allphp}",  new { allphp = @".*\.php(/.*)?" });
  
              //Default Mvc ignore.
              routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
              routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
  
              //routes.MapRoute(
              //    "404-PageNotFound",
              //     "{*url}",
              //     new { controller = "Error", action = "HttpError" }
              //);
          }
      }
  }
  </code></pre>
  
  <p>Now on my local iis everything functions as expected but when I try access urls on my production server i get the following 404.</p>
  
  <p>When I turn on my route debugging i see this on local.</p>
  
  <ol>
  <li><ul>
  <li>Matches Current Request: False</li>
  <li>Url: r.ashx/{module}/{*path}</li>
  <li>Defaults: (null)</li>
  <li>Constraints: (null)</li>
  <li>DataTokens: (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: True</li>
  <li>Url: Control/Index</li>
  <li>Defaults: controller = base, action = Index </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens: Namespaces = BookEasy.Areas.Control.*, area = Control, UseNamespaceFallback = False</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: True  </li>
  <li>Url: Control/{controller}/{action}/{id}</li>
  <li>Defaults: action = Index, id = UrlParameter.Optional </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens: Namespaces = BookEasy.Areas.Control.*, area = Control, UseNamespaceFallback = False</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: Console/Index </li>
  <li>Defaults: controller = base, action = Index </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens: Namespaces = BookEasy.Areas.Console.*, area = Console, UseNamespaceFallback = False</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: Console/{controller}/{action}/{id}</li>
  <li>Defaults: action = Index, id = UrlParameter.Optional </li>
  <li>Constraints: (empty)</li>
  <li>DataTokens: Namespaces = BookEasy.Areas.Console.*, area = Console, UseNamespaceFallback = False</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: api/{controller}/{id} </li>
  <li>Defaults:    id = </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: Error/{action}/{id} </li>
  <li>Defaults:    controller = Error, action = Generic, id = UrlParameter.Optional</li>
  <li>Constraints: (empty) </li>
  <li>DataTokens:  (empty)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: Account/Login </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: Website/{*pathInfo} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: Pages/{*pathInfo} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: {*allaspx} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: allaspx = .<em>.aspx(/.</em>)? </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: {*allasp} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: allasp = .<em>.asp(/.</em>)? </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: {*allhtml} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: allhtml = .<em>.html(/.</em>)? </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: {*allphp} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: allphp = .<em>.php(/.</em>)? </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: {resource}.axd/{*pathInfo}</li>
  <li>Defaults:    (null) </li>
  <li>Constraints: (empty) </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: False </li>
  <li>Url: {*favicon} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: favicon = (.<em>/)?favicon.ico(/.</em>)? </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: True  </li>
  <li>Url: {*catchall} </li>
  <li>Defaults:    (null) </li>
  <li>Constraints: (null) </li>
  <li>DataTokens:  (null)</li>
  </ul></li>
  </ol>
  
  <p>Sorry for that wall of text seemed to be the best way to show the data without a table. <a href="https://meta.stackexchange.com/questions/73566/is-there-any-markdown-to-create-tables">https://meta.stackexchange.com/questions/73566/is-there-any-markdown-to-create-tables</a></p>
  
  <p>Anyways on with the question.</p>
  
  <p>And now what I see when I debug routes on my deployed server.</p>
  
  <ol>
  <li><ul>
  <li>Matches Current Request: False</li>
  <li>Url: r.ashx/{module}/{*path}</li>
  <li>Defaults: (null)</li>
  <li>Constraints: (null)</li>
  <li>DataTokens: (null)</li>
  </ul></li>
  <li><ul>
  <li>Matches Current Request: True</li>
  <li>Url: {*catchall}</li>
  <li>Defaults: (null)</li>
  <li>Constraints: (null)</li>
  <li>DataTokens: (null)</li>
  </ul></li>
  </ol>
  
  <p>Some other facts.</p>
  
  <p>Mvc Version = 4</p>
  
  <p>IIS = 7</p>
  
  <p>When I remove WebApiConfig.Register(GlobalConfiguration.Configuration); the tables match (but both miss the api/* route).</p>
  
  <p>So to the core of the question. Why are these two route tables different when I add WebApiConfig.Register?</p>
  
  <p>---------------- EDIT 1 ------------------</p>
  
  <p>As another note the addition of WebApiConfig.Register also breaks my bundling routes :(.</p>