Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpUtility.ParseQueryString without decoding special characters

Uri uri = new Uri(redirectionUrl);
NameValueCollection col = HttpUtility.ParseQueryString(uri.Query)

uri.Query is already decoded - so is there any way I can prevent ParseQueryString decoding it again?

Apart from that - is there another method to retrieve a name value collection from a Uri without modifying any components?

like image 501
m.edmondson Avatar asked Jan 05 '11 12:01

m.edmondson


1 Answers

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

like image 96
volpav Avatar answered Sep 30 '22 03:09

volpav