您现在的位置是:网站首页> 编程资料编程资料
获取根目录的URL例如http://localhost:51898_实用技巧_
2023-05-24
255人已围观
简介 获取根目录的URL例如http://localhost:51898_实用技巧_
复制代码 代码如下:
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获取网站目录物理路径示例_实用技巧_
- C# web api返回类型设置为json的两种方法_实用技巧_
- .Net消息队列的使用方法_实用技巧_
- ASP.NET汉字转拼音 - 输入汉字获取其拼音的具体实现_实用技巧_
- Ajax实现异步刷新验证用户名是否已存在的具体方法_实用技巧_
- ASP.NET―001:GridView绑定List、页面返回值具体实现_实用技巧_
- 在.net中用CheckBoxList实现单选_实用技巧_
- .net中 发送邮件内容嵌入图片的具体实例_实用技巧_
- asp.net无法获取iis目录的问题解决方法_实用技巧_
- asp.net网站首页根据IP自动跳转指定页面的示例_实用技巧_
