none
WCF web service: How to map a virtual path from static constructor? RRS feed

  • Question

  • Hi,

    I need to detect some file in a WCF web service "App_Data" folder. In normal context I would just use "HostingEnvironment.MapPath", however I'm in the context of the service static constructor or in AppInitialize.

    So, the input is for example "App_Data/log4net.config" and the result must be the absolute path to that file. I can do for example:

    return Path.Combine(HostingEnvironment.ApplicationPhysicalPath, path.Replace("/", "\\"));

    But isn't there a better way? What do you Guys do when you're outside the web context like in static constructors?

    --
    Werner




    Thursday, August 22, 2013 6:15 AM

Answers