[NET]关于在ASP.NET中物理路径和虚拟路径的取得
2007-05-08 14:14
239 查看
关于在ASP.NET中物理路径和虚拟路径的取得
//Request.CurrentExecutionFilePath; 当前请求的虚拟路径 是这种格式:/虚拟目录名/admin/index.aspx//Request.ApplicationPath //获取服务器上 ASP.NET 应用程序的虚拟应用程序根路径。/虚拟目录名(应用程序名)
以上都是虚拟目录中的文件路径,即是IIS中的路径。要得到真真的物理路径要在得到以上路径的基础上再加:
Server.MapPath(Request.ApplicationPath +"SPLConfig/ClassMap.xml")//这样可能会有一个BUG
最好是这样
string m_ApplicationPath=Request.ApplicationPath;
if(this.m_ApplicationPath=="")
this.m_ApplicationPath="/";
if(!this.m_ApplicationPath.EndsWith("/"))
this.m_ApplicationPath +="/"; //先判断一下 /
Server.MapPath(m_ApplicationPath+"SPLConfig/ClassMap.xml")
2005 地址Url 的新的访问方式
//this.Request.CurrentExecutionFilePath; //当前请求的虚拟忙碌中的路径
//this.Request.FilePath; //虚拟目录中的路径
//this.Request.PhysicalPath; //当前请求的物理路径
//this.Request.PhysicalApplicationPath;//应用程序的物理路径
//this.Request.Url.AbsoluteUri;//全部URL
Request.RawUrl 获得网址带变量 Request.UrlReferrer 获得网址不带变量
刷新本页面的方法 :
this.Response.Redirect(this.Request.Url.AbsoluteUri, true);
this.Response.Redirect(this.Request.Url.ToString());
定制方法的刷新
this.Response.Redirect(this.Request.CurrentExecutionFilePath + "?depid=" + this.hDepID.Value.ToString());
相关文章推荐
- 关于在ASP.NET中物理路径和虚拟路径的取得
- 关于在ASP.NET中物理路径和虚拟路径的取得
- 关于在ASP.NET中物理路径和虚拟路径的取得
- asp.net(c#)中取得文件物理路径
- ASP.NET 中在SERVER侧获取虚拟路径对应的物理路径
- asp.net C#网站项目 获取物理路径、虚拟路径的方法
- asp.net(c#)中取得文件物理路径
- asp.net 获取项目(网站)的物理、虚拟路径的方法
- asp.net(c#)中相对路径(虚拟路径)和物理磁盘路径的转换
- asp.net C#网站项目 获取物理路径、虚拟路径的方法
- asp.net C#网站项目 获取物理路径、虚拟路径的方法
- ASP.NET中获取虚拟目录的物理路径
- asp.net取虚拟目录路径和物理路径
- [置顶] asp.net(c#)中相对路径(虚拟路径)和物理磁盘路径的转换
- ASP.NET(5):虚拟路径转换到物理路径的一种实现方法,不用MapPath
- ASP.NET的虚拟路径与物理路径
- asp.net(c#)中相对路径(虚拟路径)和物理磁盘路径的转换
- asp.net文件压缩,下载,物理路径,相对路径,删除文件
- 巧用asp.net 过滤所有的Response请求并替换部分内容,彻底解决MVC虚拟路径问题.
- Asp.net 当中的虚拟路径