How to MapPath with RequestContext in WCF Service
.net, asp.net, c#, wcf, xsd
Solution
You can use HostingEnvironment.MapPath.
Problem
This MSDN article says: `HttpContext: Current is always null when accessed from within a WCF service. Use RequestContext instead.` 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: `HttpContext.Current.Server.MapPath(schemaUri);` What would be the equivalent way using RequestContext in an IIS hosted WCF service? 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: ``` <schemas> <add uri="~/Schemas/foo.xsd" xmlNamespace="http://foo.bar/types" /> </schemas> ``` And I was trying to load like this: `var schemaUri = HttpContext.Current.Server.MapPath(schema.Uri);` Which works fine from within a normal ASP.NET website, just not an IIS hosted WCF service.