title: Append QueryString to href in asp.net core Anchor Helper Tag
body: <p>I am trying to add anything in the query of the request to anchors in the html result:</p>
  
  <p>Fictitious example:</p>
  
  <p>User makes a request (note that band and song could be anything, I have a route catering this request: template: "{band}/{song}"):</p>
  
  <pre><code>http://mydomain/band/song?Param1=111&amp;Param2=222
  </code></pre>
  
  <p>Now I want my anchors to append the query string part to the href of my anchors. So I tried something like this (note the 'asp-all-route-data'):</p>
  
  <pre><code>&lt;a asp-controller="topic" asp-action="topic" asp-route-band="iron-maiden" asp-route-song="run-to-the-hills" asp-all-route-data="@Context.Request.Query.ToDictionary(d=&gt;d.Key,d=&gt;d.Value.ToString())"&gt;Iron Maiden - Run to the hills&lt;/a&gt;
  </code></pre>
  
  <p>The append of the query string actually works with the above code but then the "iron-maiden" and "run-to-the-hills" are lost in the result. The above tag helper returns the following (note how the helper mirrors the band and song in the request into the href and not the band and song I specified in the asp-route attributes):</p>
  
  <pre><code>&lt;a href="http://mydomain/band/song?Param1=111&amp;Param2=2222"&gt;Iron Maiden - Run to the hills&lt;/a&gt;
  </code></pre>
  
  <p>I expect the following result from the helper:</p>
  
  <pre><code>&lt;a href="http://mydomain/iron-maiden/run-to-the-hills?Param1=111&amp;Param2=2222"&gt;Iron Maiden - Run to the hills&lt;/a&gt;
  </code></pre>
  
  <p>It seems like when I use the <strong>asp-all-route-data</strong> I loose the <strong>asp-route-band</strong> and <strong>asp-route-song</strong> values in the result.</p>
  
  <p>Has anybody ever stumbled across this?</p>
  
  <p>Thanks</p>
  
  <p>Hooroo</p>