首页 新闻 赞助 找找看

asp.net 内网网站做路由器映射,获取到的网站根目录是映射的地址,怎么获取本机iis上绑定的地址

0
悬赏园豆:10 [已关闭问题] 关闭于 2016-03-24 09:59

获取根目录方法如下:

/// <summary>
/// 取得网站的根目录的URL
/// </summary>
/// <param name="Req"></param>
/// <returns></returns>
public static string GetRootURI(HttpRequest Req)
{
string AppPath = "";
if (Req != null)
{
string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority);
if (Req.ApplicationPath == null || Req.ApplicationPath == "/")
//直接安装在 Web 站点
AppPath = UrlAuthority;
else
//安装在虚拟子目录下
AppPath = UrlAuthority + Req.ApplicationPath;
}
return AppPath;
}

旅行中的主页 旅行中 | 初学一级 | 园豆:122
提问于:2016-03-01 11:36
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册