title: Relative Url to Virtual Path?
body: <p>I can find lots of .NET functions that convert a <code>virtual path ("~/images/test.jpeg")</code> to a <code>relative url ("/MYSITE/images/test.jpeg")</code>, however do any functions exist that convert a Relative Url to a Virtual path?</p>
  
  <p>The alternative is to use something like:</p>
  
  <pre><code>var relativeUrl = "/MYSITE/css/reset.css";
  var appPath = System.Web.HttpRuntime.AppDomainAppVirtualPath;
  
  string virtualPath = string.Empty;
  if (relativeUrl.IndexOf(appPath, StringComparison.OrdinalIgnoreCase) == 0)
      virtualPath = relativeUrl.Substring(appPath.Length);
  ...
  </code></pre>
  
  <p>Instead.</p>
  
  <p>Thanks.</p>