Question

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.

Was it helpful?

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);

OTHER TIPS

MapPath is an instance method; you can only call it on an instance of HttpServerUtility.
If you know that your code will only be called during an HTTP request, you can call HttpContext.Current.Server.MapPath.

Otherwise, call VitualPathUtility.ToAbsolute.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top