by brad
10. August 2010 13:26
If your first experience escaping a URL in Silverlight is anything like mine, the first tool you will reach for might be HttpUtility.UrlEncode.
HttpUtility.UrlEncode(“http://www.google.com/m8/feeds/contacts/example@gmail.com/full”)
But wait! HttpUtility is in System.Web, which is definitely NOT part of the standard Silverlight reference pack. So the question now is “Do I want to include System.Web in my Silverlight application for one line of code?” And the answer is “Nope”.
Instead, you can use EscapeUriString which comes in the System assembly.
Uri.EscapeUriString(“http://www.google.com/m8/feeds/contacts/example@gmail.com/full”)
Same result, without adding a unnecessary assembly to your Silverlight application.