title: Microsoft Web API: How do you do a Server.MapPath?
body: <p>Since <em>Microsoft Web API</em> isn't <em>MVC</em>, you cannot do something like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var a = Request.MapPath("~");
  </code></pre>
  
  <p>nor this</p>
  
  <pre class="lang-cs prettyprint-override"><code>var b = Server.MapPath("~");
  </code></pre>
  
  <p>because these are under the <code>System.Web</code> namespace, not the <code>System.Web.Http</code> namespace. </p>
  
  <p>So how do you figure out the relative server path in <em>Web API</em> ?<br/>  I used to do something like this in <em>MVC</em>:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var myFile = Request.MapPath("~/Content/pics/" + filename);
  </code></pre>
  
  <p>Which would give me the absolute path on disk:</p>
  
  <pre><code>"C:\inetpub\wwwroot\myWebFolder\Content\pics\mypic.jpg"
  </code></pre>