How to stop the System.Uri class from unencoding the encoded URL passed to its constructor? Consider the following code: -
Uri uri = new Uri("http://foo.bar/foo%2FBar"); Console.WriteLine(uri.AbsoluteUri); uri = new Uri("http://foo.bar/foo%2FBar", false); Console.WriteLine(uri.AbsoluteUri); uri = new Uri("http://foo.bar/foo%2FBar", true); Console.WriteLine(uri.AbsoluteUri);
In each case, the output is "http://foo.bar/foo/bar". How can I guarantee that after creating the Uri instance, Uri.AbsoluteUri will return "http://foo.bar/foo%2FBar"?
source share