title: How to generate URL of static file (Just like ASP.NET Core UrlHelper does for action methods)?
body: <p>Is there any way to dynamically generate absolute or relative URL for a static file from physical path? Without any hard-coding. Similar to what <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.urlhelperextensions.action?view=aspnetcore-2.2#Microsoft_AspNetCore_Mvc_UrlHelperExtensions_Action_Microsoft_AspNetCore_Mvc_IUrlHelper_System_String_" rel="nofollow noreferrer">UrlHelper</a> does for action methods.</p>
  
  <p>For example, if I have a physical path:</p>
  
  <pre><code>C:\some\path\outside\wwwroot\file.jpg
  </code></pre>
  
  <p>How do I get this absolute path:</p>
  
  <pre><code>https://localhost:9000/images/file.jpg
  </code></pre>
  
  <p>Static files middleware is configured as follows:</p>
  
  <pre><code>app.UseStaticFiles(new StaticFileOptions
  {
      FileProvider = new PhysicalFileProvider(@"C:\some\path\outside\wwwroot"),
      RequestPath = "/images"
  }
  </code></pre>