Search code examples
c#asp.net.netwebmethod

Find application path from inside a web method


I'm implementing a web method inside an ASP.NET page to execute asynchronous calls. Now I need to know the physical application path of my web app.

I usually use Request.PhysicalApplicationPath, but how can I obtain the same information from inside a web method?

NOTE No Request or Server properties are available inside the web method...


Solution

  • I've always used:

    var rootPath = HostingEnvironment.ApplicationPhysicalPath;
    

    you'll need to also add using System.Web.Hosting; in your class directives header