手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >获取根目录的URL例如http://localhost:51898
获取根目录的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】相关文章:

gridview 行选添加颜色和事件

asp.net Split分割字符串的方法

用ASP.NET还原与恢复Sql server

asp.net获取网站目录物理路径示例

php获取301跳转URL简单实例

页面包含的处理

C#(.NET)数据访问连接、查询、插入等操作的封装类

ASP.NET缓存方法分析和实践示例代码第1/2页

Asp.net实现向上向下排序的例子

如何合并多个 .NET 程序集

精品推荐
分类导航