asp.net 正确获取当前URL

来源:互联网 发布:远程连接软件 编辑:程序博客网 时间:2024/05/18 06:50
 获取当前URL我一直使用HttpContext.Current.Request.Url.ToString(),今天Tinyfool指出我的一个Bug,调试发现,ToString()函数并不可靠。如果当前URL为http://localhost/search.aspx?user=tinyfool&tag=%BC%BC%CA%F5通过HttpContext.Current.Request.Url.ToString()获取到的却是http://localhost/search.aspx?user=tinyfool&tag=¼¼Êõ这显然不对,怎么办?用HttpContext.Current.Request.Url.PathAndQuery好了,这个得到的正确的。:)