手机
当前位置:查字典教程网 >编程开发 >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】相关文章:

.Net下的签名与混淆图文分析

ASP.NET方法如何重载的必备条件

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

获取字符串数组的最后一段字符

asp.net DataGridView导出到Excel的三个方法[亲测]

使用linq读取分隔符文本文件

上传图片前判断文件格式与大小验证文件是不是图片

让Silverlight 2.0动画动起来Making Silverlight 2.0 animation Start(不能运动原因)

.net获取本机公网IP地址示例

让VS2008对JQuery语法的智能感知更完美一点

精品推荐
分类导航