获取网站根目录地址(绝对路径地址)

    ///
        /// 获取路径
        ///

        ///
        public string GetRootURI()
        {
            string AppPath = "";
            HttpContext HttpCurrent = HttpContext.Current;
            HttpRequest Req;
            if (HttpCurrent != null)
            {
                Req = HttpCurrent.Request;
                string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority);
                if (Req.ApplicationPath == null || Req.ApplicationPath == "/")
                {
                    AppPath = UrlAuthority;
                }
                else
                {
                    AppPath = UrlAuthority + Req.ApplicationPath;
                }
            }
            return AppPath;
        }

你可能感兴趣的:(获取网站根目录地址(绝对路径地址))