title: How to get value of id in Url from Razor View in ASP.NET Core
body: <p>I have a simple ASP.NET Core web application with a page like such <code>http://localhost:5050/Posts/Create/3</code>.</p>
  
  <p>In my Razor View <code>Views/Posts/Create.cshtml</code>, how would I be able to get the value "3" so that I can create a link like <code>&lt;a href="/Blogs/Details/3"&gt;« Back to Blog&lt;/a&gt;</code>?</p>
  
  <p>So far, created the link using the following Tag Helper, but I don't know what to put for <code>asp-route-id</code>:</p>
  
  <pre><code>&lt;a asp-controller="Blogs" asp-action="Details" asp-route-id="" class="btn btn-default btn pull-right"&gt;&amp;laquo; Back&lt;/a&gt;
  </code></pre>
  
  <p>I am just using the default mvc route:</p>
  
  <pre><code>app.UseMvc(routes =&gt;
  {
      routes.MapRoute(
          name: "default",
          template: "{controller=Home}/{action=Index}/{id?}");
  });
  </code></pre>
  
  <p>I know I can get it from the Model (i.e., <code>Model.Blog.BlogId</code>), but I'm looking to get it from the Url using something like <code>Request.Query["id"]</code> in <code>Views/Post/Create.cshtml</code>.</p>
  
  <p>I tried <code>asp-route-id="@Context.Request.Query["id"]</code>.</p>