Reputation: 409
I have the following C# code Uri uri = new Uri("http://localhost/query?param=%E2%80%AE");
and uri
interprets it like http://localhost/query?param=
instead of http://localhost/query?param=%E2%80%AE
. As a result http web server gets http://localhost/query?param=
(without value of this parameter). Why does it break my url and how can I create HttpWebRequest
correctly using my http://localhost/query?param=%E2%80%AE
?
P.S. I have got the %E2%80%AE
using System.Uri.EscapeDataString(Convert.ToString((char)8238))
.
Upvotes: 1
Views: 258
Reputation: 5369
This is kind of mis-using of the methods exposed.
Upvotes: 0
Reputation: 134841
ToString()
will try to render the uri as a string. i.e., it will unescape escaped characters. However the escaped sequence %E2%80%AE
is not printable.
Use the AbsoluteUri
instead.
var uriStr = uri.AbsoluteUri; // "http://localhost/query?param=%E2%80%AE"
Upvotes: 1