Mono - Uri class
I am making an HttpWebRequest at a url similar to this:
"http://mysite.com/search?query=my+search+string"
Problem is, the Uri class escapes it with %, and the site I'm making the request against can't handle the escaped characters. (I have no control to fix the site)
So tried this [Obsolete] constructor:
new Uri(myUriString, true);
But it did not seem to make any difference, when debugging, my Uri still got escaped.
I am running this on a Mac with Mono, but开发者_C百科 I have not tried it on standard .Net on Windows to see if it has the same behavior.
Is there another way to get around this issue?
I ran
Uri uri = new Uri("http://mysite.com/search?query=my+search+string");
Console.WriteLine(uri.ToString());
through Microsoft .NET Runtime and Mono on a Windows 7 machine and it did not escape the characters. Are you sure this URL isn't getting appended to another url where it thinks this is a query parameter?
Sadly, I don't see a way around this. Escaping characters via hexcodes is in the Uri spec and should be adhered by the server.
精彩评论