title: ActionLink with Attribute Routing in MVC 5
body: <p>I'm having trouble with an ActionLink in MVC 5.</p>
  
  <pre><code>@Html.ActionLink("View Commissions", "/" + item.Id.ToString, "Commissions") 
  @Html.ActionLink("View Commissions", "Index", "Commissions", New With {Key .payRollId = item.Id}, Nothing)
  </code></pre>
  
  <p>These two ActionLinks should accomplish the same thing, but I would prefer to use the second one. Unfortunately, they produce different URLs. The first creates <code>http://mysite/Commissions/3</code>. The second creates <code>http://mysite/Commissions?payRollId=3</code>.</p>
  
  <p>In my Commissions controller, I have the following code:</p>
  
  <pre><code>    ' GET: Commissions/5
      &lt;Route("Commissions/{payRollId:min(1)}")&gt;
      Async Function Index(ByVal payRollId As Integer?) As Task(Of ActionResult)
          If IsNothing(payRollId) Then
              Return New HttpStatusCodeResult(HttpStatusCode.BadRequest)
          End If
  
          Return View(Await ...query...).ToListAsync)
      End Function
  </code></pre>
  
  <p>This successfully handles the first ActionLink's URL. The second one results in a 404 error. I don't have any other RouteAttributes or mapped routes for Commissions. According to this <a href="http://www.ehsanghanbari.com/Post/114/attribute-routing-with-aspnet-mvc5" rel="nofollow">attribute routing article</a>, the second ActionLink should create the pretty URL (no query string) that successfully  handles the request.</p>
  
  <p>What am I missing? How can I get the second ActionLink to generate the proper URL (<code>Commissions/3</code>) to match the RouteAttribute?</p>