W开发者_如何学JAVAhat is the difference between those two? If I only want to retrieve the absoluate path to an image on web server, is Server.MapPath safer in any case? I'm using Page.MapPath right now, but it won't work if control was created in WebService since control.Page property become null? Whether Server.MapPath always work?
I have seem through Reflector and it seems both methods end up calling the same base method.
So you can use whichever fits better.
If you don't have the Page
, you can get it through the context handler. (It will be null if you are not actually in a page).
var Page = HttpContext.Current.Handler as Page;
精彩评论