title: MVC2 Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!
body: <p>I have a WCF service that lives side-by-side with an MVC2 web site. I'd like for my URL for the service to look like this:</p>
  
  <p><code>http://localhost/projdir/Service</code></p>
  
  <p>The MVC site is in its infancy so it still has all its boilerplate controllers etc.  </p>
  
  <p>The following code works at first glance in global.asax:</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
  {
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
      routes.Add(new ServiceRoute("Service", new ServiceHostFactory(), 
                 typeof(MyService)));
  
      routes.MapRoute(
          "Default", // Route name
          "{controller}/{action}/{id}", // URL with parameters
          new { controller = "Home", action = "Index", 
                id = UrlParameter.Optional } // Parameter defaults
      );
  }
  </code></pre>
  
  <p>The service appears just where I described and works as advertised. Great.</p>
  
  <p>However, I just noticed that ordering my code this way changes all of my <code>ActionLink</code>'s. For example, the "About" tab on the MVC site now appears like this:</p>
  
  <p><code>http://localhost/projdir/Service?action=About&amp;controller=Home</code></p>
  
  <p>This is obviously incorrect (it should be <code>http://localhost/projdir/Home/About/</code> ). </p>
  
  <p>If I move the <code>ServiceRoute</code> addition below the default <code>MapRoute()</code> call, then I get a missing controller error. (Actually I get a "StructureMapControllerFactory did not return an instance of a controller" error, because I'm wired up with StructureMap, duh, it's not a controller to begin with.)</p>
  
  <p>Interestingly, it only seems to be affecting the output of <code>Html.ActionLink()</code>. I can manually type in <code>http://localhost/projdir/Home/About/</code> and get to the correct page. </p>
  
  <p>What horribly obvious newbie mistake am I making?</p>