获取根目录的URL例如http://localhost:51898_asp.net教程-查字典教程网
获取根目录的URL例如http://localhost:51898
获取根目录的URL例如http://localhost:51898
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下: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;

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新asp.net教程学习
    热门asp.net教程学习
    编程开发子分类