ASP.NET获取当前网址方法
2010-08-11 01:09
363 查看
ASP.NET获取当前网址方法
引自:/article/5960386.html
ASP.NET获取浏览器URL
HttpContext.Current.Request.Url.ToString(); 并不可靠。
如果当前URL为
http://localhost/index.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5
通过HttpContext.Current.Request.Url.ToString()获取到的却是
http://localhost/index.aspx?user=http://csharp.xdowns.com&tag=¼¼Êõ
正确的方法是:HttpContext.Current.Request.Url.RawUrl; (实用伪静态)或 HttpContext.Current.Request.Url.PathAndQuery;(实用非伪静态)
如果测试的url地址是http://www.test.com/testweb/default.aspx, 结果如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PhysicalApplicationPath: E:\WWW\testwebRequest.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUrl: http://www.test.com/testweb/default.aspx
Request.Url.Host: http://www.test.com/
Request.Url.LocalPath: /testweb/default.aspx
引自:/article/5960386.html
ASP.NET获取浏览器URL
HttpContext.Current.Request.Url.ToString(); 并不可靠。
如果当前URL为
http://localhost/index.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5
通过HttpContext.Current.Request.Url.ToString()获取到的却是
http://localhost/index.aspx?user=http://csharp.xdowns.com&tag=¼¼Êõ
正确的方法是:HttpContext.Current.Request.Url.RawUrl; (实用伪静态)或 HttpContext.Current.Request.Url.PathAndQuery;(实用非伪静态)
如果测试的url地址是http://www.test.com/testweb/default.aspx, 结果如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PhysicalApplicationPath: E:\WWW\testwebRequest.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUrl: http://www.test.com/testweb/default.aspx
Request.Url.Host: http://www.test.com/
Request.Url.LocalPath: /testweb/default.aspx
相关文章推荐
- ASP.NET获取当前网址方法
- ASP.net获取当前网址url各种属性(文件名、参数、域名 等)的方法-转
- ASP.net获取当前url各种属性(文件名、参数、域名等)的方法[转载]
- ASP.net获取当前url各种属性(文件名、参数、域名等)的方法
- ASP.NET总结C#中7种获取当前路径的方法
- asp.net获取当前网址url的各种属性(文件名、参数、域名 等)的代码
- Asp.net 获取当前目录的三种方法
- ASP.NET获取当前用户的方法属性大整合
- asp.net中获取当前url的方法
- asp.net获取当前网址url的各种属性(文件名、参数、域名 等)的代码
- Asp.net技巧:gridview获取当前行索引的方法
- ASP.net获取当前url各种属性(文件名、参数、域名 等)的方法
- ASP.NET(c#)中实现获取当前网站的域名网址
- asp.net获取当前网址url
- asp.net获取当前页面文件名,参数,域名等方法
- asp.net中获取当前url的方法
- C#(ASP.Net)获取当前路径的方法集合
- asp.net获取当前网址url的各种属性(文件名、参数、域名 等)的代码
- asp.net获取系统当前时间的方法详解
- asp.net获取当前网址url