获取站台根路径

来源:互联网 发布:有必要买ipad吗 知乎 编辑:程序博客网 时间:2024/04/27 15:35
    /// <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;
    }