title: How to MapPath with RequestContext in WCF Service
body: <p>This <a href="http://msdn.microsoft.com/en-us/library/aa702682.aspx" rel="noreferrer">MSDN article</a> says:</p>
  
  <p><code>HttpContext: Current is always null when accessed from within a WCF service. Use RequestContext instead.</code></p>
  
  <p>What I'm trying to do is load some XSD files in from my IIS hosted WCF service. Problem is, I can't figure out how to do a Server.MapPath() like I would in any old vanilla ASP.NET website, something like:</p>
  
  <p><code>HttpContext.Current.Server.MapPath(schemaUri);</code></p>
  
  <p>What would be the equivalent way using RequestContext in an IIS hosted WCF service?</p>
  
  <p>The schemas are located in a "Schemas" directory at the root of the service application. They're referenced using a custom config section in the web.config like this:</p>
  
  <pre><code>&lt;schemas&gt;
      &lt;add uri="~/Schemas/foo.xsd" xmlNamespace="http://foo.bar/types" /&gt;
  &lt;/schemas&gt;
  </code></pre>
  
  <p>And I was trying to load like this:</p>
  
  <p><code>var schemaUri = HttpContext.Current.Server.MapPath(schema.Uri);</code></p>
  
  <p>Which works fine from within a normal ASP.NET website, just not an IIS hosted WCF service.</p>