Preserve url when using a URI class in .NET 3.5

I am using .NET 3.5.

Both solutions described here (property "genericUriParserOptions"in the configuration file and constructor parameter "dontEscape") do not work for .NET 3.5.

I want the constructor URInot to be deleted (which means I want you to have shielded parts URL). Now I can not use the configuration file with

genericUriParserOptions="DontUnescapePathDotsAndSlashes"

bacause this property is available only for .NET 4.0. But I can not use the parameter "dontEscape"in the constructor URI, because the constructor is deprecated in .NET 3.5 and always false.

How can I create URIwith escaped string in .NET 3.5?

+5
source share
1 answer

URL-, . URL- URL- , :

string url = HttpUtility.UrlEncode("http://www.google.com/search?q=Example");

http%3a%2f%2fwww.google.com%2fsearch%3fq%3dExample

, , . / , :

string url = "http://www.google.com/search?q=" + HttpUtility.UrlEncode("Example");

.

+1

All Articles