c# - QueryString Out of Encoded URL -


i have encoded url.

http%3a%2f%myurl.test.me%2fsometjing%2fproduct%2fsearch%3fq=tomato 

i trying query string out of url "tomato". using following code returns null.

 var parsedquery = httputility.parsequerystring((url));             console.write(parsedquery["q"]); // null  

you're missing few steps. need decode url, pull out query string, , parse query string:

string decoded =      httputility.urldecode("http%3a%2f%2fmyurl.test.me%2fsometjing%2fproduct%2fsearch%3fq=tomato");  var uri = new uri(decoded); var parsedquery = httputility.parsequerystring(uri.query);  console.writeline (parsedquery["q"]); // tomato 

also, encoded url little malformed. 1 in post decoded looks this:

http:/%myurl.test.me/sometjing/product/search?q=tomato

i think missed 2f after % right before myurl.test:

http%3a%2f%2fmyurl.test.me%2fsometjing%2fproduct%2fsearch%3fq=tomato


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -