天涯之外

导航

asp.net 获取当前URL的正确方法

 
HttpContext.Current.Request.Url.ToString() 并不可靠。

如果当前URL为
http://localhost/search.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5

通过HttpContext.Current.Request.Url.ToString()获取到的却是

http://localhost/search.aspxuser=http://csharp.xdowns.com&tag=¼¼Êõ


正确的方法是:HttpContext.Current.Request.Url.PathAndQuery

posted on 2009-05-13 11:47  天涯之外  阅读(162)  评论(0编辑  收藏  举报