I am working on an asp.net mvc web application. now i have a value for operating system which equal to :-
and i am using the following code to build a url containing the above value as follow:-
var query = HttpUtility.ParseQueryString(string.Empty);
query["osName"] = OperatingSystem;
var url = new UriBuilder(apiurl);
url.Query = query.ToString();
string xml = client.DownloadString(url.ToString());
but the generated url will contain the following value for the operating system :-
osName=Microsoft%u00ae+Windows+Server%u00ae+2008+Standard
so the UriBuilder will encode the registered sign as %u00ae+
which is wrong since when i try to decode the %u00ae+
using online site such as http://meyerweb.com/eric/tools/dencoder/ it will not decode %u00ae+
as register sign ??? so can anyone adivce on this please, how i can send the registered sign inside my url ? is this a problem within UrilBuilder ?
Thanks
EDIT This will clearly state my problem.. now i pass the asset name valueas £ ££££££ now the query["assetName"] will get the correct value.. but inside the query the value will get encoded wrongly (will not be encoded using UTF8 )!!!
Try this:
url.Query = Uri.EscapeUriString(HttpUtility.UrlDecode(query.ToString()));
As mentioned here HttpUtility.ParseQueryString() always encodes special characters to unicode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With