IIS 的当前网站路径

来源:互联网 发布:德国网络攻击战略 编辑:程序博客网 时间:2024/06/05 14:46

IIS 的当前网站路径(例子:获取服务器或本地图片路径):

 方法一:string strUrl =HttpContext.Current.Request.Url.Scheme(http) + "://"  +   HttpContext.Current.Request.Url.Authority(主机+端口) + "/Goods/1245.jpg";

如:http://localhost:端口/Goods/1245.jpg 


 方法二:string strUrl = HttpContext.Current.Server.MapPath("/Goods/1245.jpg");

如:http://www.baidu.com/Goods/1245.jpg 
原创粉丝点击