获取网站根目录地址(绝对路径地址)
2013-03-24 08:26
253 查看
/// <summary>
/// 获取路径
/// </summary>
/// <returns></returns>
public 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 == "/")
{
AppPath = UrlAuthority;
}
else
{
AppPath = UrlAuthority + Req.ApplicationPath;
}
}
return AppPath;
}
/// 获取路径
/// </summary>
/// <returns></returns>
public 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 == "/")
{
AppPath = UrlAuthority;
}
else
{
AppPath = UrlAuthority + Req.ApplicationPath;
}
}
return AppPath;
}
相关文章推荐
- js获取网站根路径(站点及虚拟目录),获得网站的根目录或虚拟目录的根地址
- js获取网站根路径(站点及虚拟目录),获得网站的根目录或虚拟目录的根地址
- php获取网站根目录物理路径的几种方法(推荐)
- jsp中获取当前服务器上所在目录的绝对路径
- java获取WEB-INF目录绝对路径
- 得到站点的绝对地址--weblogic获取路径总是为NULL
- 获取网站的绝对路径
- Javascript中使用A标签获取当前目录的绝对路径方法
- PHP中如何获取网站根目录物理路径
- Android获取drawable目录下的图片绝对路径并转为Bitmap
- 关于获取Tomcat和WebSphere的classes目录的绝对路径的问题
- asp.net中获取网站绝对路径的方法
- linux c 获取一个文件or目录的绝对路径
- ASP.NET获取网站根目录(路径)
- 获取指定目录及其子目录下所有文件的绝对路径
- 获取网站虚拟目录下的物理路径
- JS获取当前网址,JS获取当前域名URL ,JS获取网站完整路径页面地址
- Symfony2获取web目录绝对路径、相对路径、网址的方法
- linux获取用户主目录的绝对路径
- 网站获取非根目录下面的文件---虚拟路径