title: Html.ActionLink rendering non-route URL
body: <p>This is probably stupid, but I can't seem to figure it out. I'm using <code>Html.ActionLink</code> to create links between master and child pages: <code>Employees -&gt; Employee</code>.</p>
  
  <p>I just noticed that the URL it's rendering is not "shaped" as the route it's supposed to match. For example the URL being generated is <code>/Employee?EmployeeId=?</code> when it's supposed to be <code>/Employees/{EmployeeId}</code>.</p>
  
  <p>Am I missing something that's supposed to make it return that kind of a url? I was hand writing all the links up until 2 weeks ago when I switched to <code>Html.ActionLink</code> and I could have sworn it was working properly, but now I see this pattern everywhere on my app and I don't like it...</p>
  
  <p><code>Url.Action</code> and <code>Html.RouteLink</code> create the same URL as well.</p>
  
  <p>Help would be appreciated.</p>
  
  <p><strong>UPDATE</strong> for @Darin</p>
  
  <p>Here's how the route is registered:</p>
  
  <pre><code>Routes.MapRoute("QbNn7GFjJZBzYED7", Settings.EmployeeRoute, new {
      action = "Employee"
  }, new {
      controller = new ControllerConstraint(Settings.AdministrationController),
      group = new GroupConstraint(Settings.CorporateGroup),
      EmployeeId = @"\d+"
  });
  
  Settings.EmployeeRoute = "{controller}/{group}/Employees/{EmployeeId}";
  Settings.AdministrationController = "Administration";
  Settings.CorporateGroup = "Corporate";
  </code></pre>
  
  <p>And before you ask why the route name is <code>QbNn7GFjJZBzYED7</code>, it's because I got tired of giving the routes names and because I never refer to the routes by their name, so I just started generating random strings to fill in the void.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>The two constraints were essentially the same with different names. Thus, I merged it into one and here's what it looks like:</p>
  
  <pre><code>internal class NameConstraint : IRouteConstraint {
      private readonly string[] Names = new string[0];
  
      public NameConstraint(
          string Name) {
          this.Names = new string[1] {
              Name.ToLower()
          };
      }
  
      public NameConstraint(
          string[] Names) {
          this.Names = Names.Select(
              n =&gt;
                  (n.ToLower())).ToArray();
      }
  
      public bool Match(
          HttpContextBase HttpContextBase,
          Route Route,
          string Paramater,
          RouteValueDictionary RouteValueDictionary,
          RouteDirection RouteDirection) {
          string Param = ((string)RouteValueDictionary[Paramater]).ToLower();
  
          return this.Names.Contains(Param);
      }
  }
  </code></pre>
  
  <p>Now, between this update and the previous one, the routes fixed themselves. The only change that happened was taking <code>ControllerConstraint</code> and <code>GroupConstraint</code> and merging them into <code>NameConstraint</code> and the subsequent rebuild.</p>
  
  <p>How it decided to fix itself, I don't know, but it did. I don't think it was the merger of the constraints, and I doubt it was the rebuild.</p>
  
  <p>Now both of these are generating the right routes:</p>
  
  <pre><code>Html.ActionLink(Employee.Name, "Employee", new { EmployeeId = Employee.EmployeeId })
  Html.ActionLink(Employee.Name, "Employee", "Administration", new { group = "Corporate", EmployeeId = Employee.EmployeeId }, null)
  </code></pre>
  
  <p>In the end I'm not sure what the actual fix was...</p>