获取根目录的URL例如http://localhost:51898
摘要:复制代码代码如下:publicstaticstringGetRootURI(){stringAppPath="";HttpContextHt...
复制代码 代码如下:
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;
}
【获取根目录的URL例如http://localhost:51898】相关文章:
★ asp.net DataGridView导出到Excel的三个方法[亲测]
★ 让Silverlight 2.0动画动起来Making Silverlight 2.0 animation Start(不能运动原因)
上一篇:
asp.net获取网站目录物理路径示例
下一篇:
asp.net后台弹窗如何实现