获取根目录的URL例如http://localhost:51898
时间:2021-05-15 09:07:30|栏目:.NET代码|点击: 次
复制代码 代码如下:
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;
}
上一篇:基于Dapper实现分页效果 支持筛选、排序、结果集总数等
栏 目:.NET代码
下一篇:gridview行索引获取方法及实现代码(非js版)
本文标题:获取根目录的URL例如http://localhost:51898
本文地址:http://www.codeinn.net/misctech/122042.html






