您的位置:首页 > 运维架构 > 网站架构

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

2013-03-24 08:26 253 查看
    /// <summary>

        /// 获取路径

        /// </summary>

        /// <returns></returns>

        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;

        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: