title: How to generate an URL from a route template in ASP.NET Core
body: <p>I have two separate ASP.NET Core sites <code>A1</code> and <code>A2</code> based on a same shared library <code>B</code>.</p>
  
  <p><code>A1</code> and <code>A2</code> are on a1.example.com and a2.example.com, and they have controllers with route templates looking like</p>
  
  <p><code>A1</code>: </p>
  
  <pre><code>[HttpGet("/Feature1/{featureId}/EditEntry/{entryId}", Name = "EditFeature1Entry")]
  public IActionResult EditFeature1Entry(long featureId, Guid entryId, string token)
  {
      [...]
  }
  </code></pre>
  
  <p>In project <code>A1</code>, I would generate an URL using </p>
  
  <pre><code>var url = Url.RouteUrl("EditFeature1Entry", new {featureId = 3, entryId = someGuid, token})
  </code></pre>
  
  <p>it would generate:</p>
  
  <pre><code>url = "/Feature1/3/EditEntry/someGuid?token=token"
  </code></pre>
  
  <p>But to build the same url from <code>A2</code>, I need to generate the URL myself as the route is not registered in the project <code>A2</code> (the controller is in project <code>A1</code>). </p>
  
  <p><strong>What I would like to do</strong> is to put the templates somewhere in the library <code>B</code> and use an URL generator to be able to do something like </p>
  
  <pre><code>var url = Url.RouteUrlFromTemplate("/Feature1/{featureId}/EditEntry/{entryId}", new {featureId = 3, entryId = someGuid, token}, "https", "a1.example.com", null);
  </code></pre>
  
  <p>in order to generate</p>
  
  <pre><code>url = "https://a1.example.com/Feature1/3/EditEntry/someGuid?token=token"
  </code></pre>
  
  <p>Is there any pre-built tool for that or should I do it myself? 
  I feel I could use a large part of what exists in the current Url builder, but I would prefer to rely on the framework :)</p>