When developing my initial MonoTouch iOS application I was trying to use System.Uri instances to download protected resources from a private web service but as all instances are always returning unescaped URLs, my requests are failing when having their signature checked.
Example of a good request:
http://example.com/folder%2Ftest?signature=000%3D
Example of a bad request:
http://example.com/folder/test?signature=000=
In order to properly download my resources I need to convert a good URL from a simple string to a good Uri instance. I have just started the process but I am not able to conclude it:
string urlStringVersion = "http://example.com/folder%2Ftest?signature=000%3D";
//
// urlStringVersion == http://example.com/folder%2Ftest?signature=000%3D
Uri urlUriVersion = new Uri (urlStringVersion);
//
// urlUriVersion == http://example.com/folder/test?signature=000=
var fi = typeof (Uri).GetField ("host", BindingFlags.NonPublic | BindingFlags.Instance);
fi.SetValue (urlUriVersion, "example.com");
//
// urlUriVersion.AbsoluteUri is now == http://example.com/folder/test?signature=000%3D
<Another C# command here>
//
// urlUriVersion.AbsoluteUri is now == http://example.com/folder%2Ftest?signature=000%3D
Finally, which command may I be using to replace the Another C# command here in order to have my final urlUriVersion.AbsoluteUri pointing to the same initial urlStringVersion described URL?
I need this conversion working, otherwise I will be forced to make my resources public at my private web service.
I have also tested some alternatives:
From other questions like: GETting a URL with an url-encoded slash but some exceptions are happening:
System.NullReferenceException : Object reference not set to an instance of an object
Using configuration files but in this case since mobile devices don't technically have an Application Domain they are not available.
Double-encoding the URL by replacing the percent signs with an encoded percent sign (so '%' becomes '%25').
None of my tries solved my problem.
Thanks in advance,
Piva