获取根目录的URL 获取根目录的URL例如http://localhost:51898
人气:0想了解获取根目录的URL例如http://localhost:51898的相关内容吗,在本文为您仔细讲解获取根目录的URL的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:根目录,URL,下面大家一起来学习吧。
复制代码 代码如下:
public static 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 == "/")
//直接安装在 Web 站点
AppPath = UrlAuthority;
else
//安装在虚拟子目录下
AppPath = UrlAuthority + Req.ApplicationPath;
}
return AppPath;
}
加载全部内容