开发者

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

开发者 https://www.devze.com 2022-12-23 14:12 出处:网络
I imported system.web into my class lib project. Trying to find: system.web.httpserverutility.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 inte开发者_运维知识库llisense?

It is a .net 2.0 build.


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消