Search code examples
c#asp.netserver.mappath

Imported system.web, I don't see server.mapPath?


I imported system.web into my class lib project.

Trying to find:

system.web.httpserverutility.server.mappath

But I dont' get the method in intellisense?

It is a .net 2.0 build.


Solution

  • The method is accessible via the System.Web.HttpContext.Current.Server object. Just set a reference to System.Web.HttpContext.Current.Server and call the method like normal.

    var server = HttpContext.Current.Server;
    server.MapPath(SOME_VIRTUAL_PATH);