title: asp.net mvc image path and virtual directory
body: <p>I know this has to be a duplicate, but I've been wading through the hordes of information on this and I can't get it work.</p>
  
  <p>I'm trying to get a site working on a client's server and they have the site installed in a virtual directory.  I don't have this setup, locally, so I'm flying blind here.</p>
  
  <p>I'm trying to build a path to an image. (it's for Facebook OpenGraph Meta data).  </p>
  
  <p>I need the path to the image to be a fully-qualified, absolute url.  I've tried so many things, but nothing seems to work.  The code below outputs a relative url, but this will not work.</p>
  
  <pre><code>&lt;% var urlHelper = VirtualPathUtility.ToAbsolute("~/static/images/image.jpg");%&gt;
  &lt;meta property="og:image" content="&lt;%=urlHelper%&gt;" /&gt;
  </code></pre>
  
  <p>outputs:</p>
  
  <pre><code>&lt;meta property="og:image" content="/static/images/image.jpg" /&gt; 
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>&lt;% var serverHost = HttpContext.Current.Request.Url; %&gt;
  &lt;meta property="og:image" 
            content="&lt;%=serverHost + "/static/images/image.jpg"%&gt;" /&gt;
  </code></pre>
  
  <p>But that's producing:</p>
  
  <pre><code>&lt;meta property="og:image" 
     content="http://localhost:51863/ViewFile.aspx/static/images/image.jpg" /&gt;
  </code></pre>
  
  <p>I'm looking for <a href="http://example.com/virtualdirectory/static/images/image.jpg" rel="nofollow">http://example.com/virtualdirectory/static/images/image.jpg</a></p>
  
  <p>Any help will be much appreciated.  I really don't want to have to hard-code the url.</p>
  
  <p>Thanks,
  Scott</p>
  
  <h2>EDIT</h2>
  
  <p>I neglected to mention that my very first attempt was Url.Content("~/....jpg) but that outputs a relative url, not an abosolute one.</p>