博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

获取Web站点根目录的绝对地址

Posted on 2010-07-05 22:34  Mr.Night  阅读(638)  评论(0)    收藏  举报
1 public static Uri GetAbsoluteWebSiteRoot()
2 {
3     return new Uri(System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/"));
4 }