Uri constructor with dontEscape is obsolete, what is alternatieve?

c#, escaping, httpwebrequest, uri

Solution

use this

Uri uri = new Uri(Uri.EscapeUriString(URL)); 

Problem

My question is regarding passing an URL to HttpWebRequest without escaping, I searched the forums and internet, but I didn't find a good solution for it. I have following URL:`string URL= www.website.com/sub/redirec\t\bs\dd` So when I create an uri like this: ``` Uri uri = new Uri(URL); HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri); ``` In this case on a get method I will get following URL:`www.website.com/sub/redirect%5Ct%5Cbc%5Cdd` This sign "\" will be replaced by "%5C". What is crucial for me not to happen? I can avoid that by: ``` Uri uri = new Uri(URL, true); //bool dontEscape ``` But this constructor is obsolete. How to have same effect without using obsolete?

Original source