title: HostingEnvironment.MapPath(path) returning null in WCF application
body: <p>Having some problems trying to get <code>HostingEnvironment.MapPath()</code> to work with my WCF app.</p>
  
  <p>I created a class with a static method to check to see if <code>HttpContext.Current</code> is null:</p>
  
  <pre><code>public class ServerPath
  {
      public static string MapPath(string path)
      {
          string result;
          if (HttpContext.Current != null)
              result = HttpContext.Current.Server.MapPath(path);
          result = HostingEnvironment.MapPath(path);
  
          return result;
      }
  }
  </code></pre>
  
  <p>and everything I through at it just returns null (<code>ServerPath.MapPath(~/file.xml")</code> and <code>Server.PathPath("./file.xml")</code>).  If anyone is wondering why I have 'string result'; it is because I added <code>if (string.IsNullOrEmpty(result))</code> and added <code>result = Directory.GetCurrentDirectory() + path;</code></p>
  
  <p>Has anyone else experienced issues like this when testing with the WCF test client?</p>
  
  <p>Do let me know if it is something to do with the binding/need to see an example of it.</p>
  
  <p>Before I forget, I have <code>&lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt;</code> within the <code>system.serviceModel</code> in my <code>app.config</code> as well.</p>