HttpUtility.ParseQueryString without decoding special characters

孤者浪人 提交于 2019-12-05 01:19:45

Encoding the uri.Query before passing it to ParseQueryString is the first thing that comes to my head.

UPDATE

Just checked the ParseQueryString method with Reflector: it assumes that the query string is encoded and you can't do anything with it... Bummer. So I think you need to parse it manually (there are plenty of ready-to-use algorithms on the Web).

Alternatively you could encode your query string properly (taking into account variable names and all special characters) before passing it to ParseQueryString method.

-- Pavel

I have faced the same problem. The solution is adding the second parameter - the encoding. It seams that everything works if you set UTF8 encoding.

NameValueCollection col = HttpUtility.ParseQueryString(uri.Query, Encoding.UTF8)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!