title: Distinguish between web api routes and mvc routes
body: <p>I started developing an application supported by <strong>Web API 2</strong>, because I just wanted to retrieve data in a RESTful way.</p>
  
  <p>Then I needed to add some HTML to the site in order to allow administrators manage the information provided, so I created some <strong>MVC 5</strong> controller to return HTML. Now I want to distinguish between Web API routes and MVC routes, without affecting, if possible, Web API routes, which are in production.</p>
  
  <p><strong>Web API routes: My mistake here was removing the "api" prefix when I firstly developed this, which would have solved the collision now</strong></p>
  
  <pre><code>public static void Register(HttpConfiguration config)
  {
      // Web API routes
      config.MapHttpAttributeRoutes();
      config.Routes.MapHttpRoute(
          name: "DefaultApi",
          routeTemplate: "{controller}/{action}/{id}",
          defaults:
              new {
                   controller = "Parking",
                   action = "Get",
                   id = RouteParameter.Optional
                   }
          );
  }
  </code></pre>
  
  <p><strong>MVC Routes: default routing. MVC Controller name is Administration, that is, MVC routes are intended for administration site only</strong></p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
  {
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
      routes.MapRoute(
          name: "Default",
          url: "{controller}/{action}/{id}",
          defaults: new { controller = "Parking", action = "Get", id = UrlParameter.Optional }
      );
  }
  </code></pre>
  
  <p>The problem is that MVC routes don't have the opportunity to match because WebAPI routes match first. It doesn't really matter how MVC routes need to be changed as long as they just <strong>work</strong>, since they are not in production yet; it's better for me to <strong>keep Web API routes</strong> as they are now.</p>
  
  <p>I've tried:</p>
  
  <ul>
  <li>Switching the order of registration of web api routes and mvc routes in Global.asax.cs</li>
  <li>Using "web" as prefix for the MVC controllers, but the routing mechanism thinks "web" is a controller and it is not found (Web api routing wins again).</li>
  <li>I couldn't come up with a proper constraint to avoid this collision.</li>
  <li>Hardcode "Administration" replacing "{controller}" in the MVC route pattern.</li>
  </ul>
  
  <p>Is there some trick here to resolve the collision?</p>