Reputation: 2234
The regular .Net framework contains HttpUtility.UrlEncode in the System.Web Assembly and in Silverlight it appears it was moved to System.Windows.Browser. But in Windows Phone 7 (which I thought was the same as Silverlight) I can't seem to find a proper way to UrlEncode anything. Neither of the previously mentioned assemblies are available in the Windows Phone 7 environment.
Upvotes: 34
Views: 15740
Reputation: 769
Now it is solved. You can use :
Windows.Data.Html.HtmlUtilities.ConvertToText("your_html_string");
Upvotes: 0
Reputation: 3835
HttpUtility.UrlEncode
and HttpUtility.UrlDecode
are in Windows Phone 7, they just got moved.
Look for them in System.Net.HttpUtility
in assembly System.Windows.dll.
Upvotes: 25
Reputation: 69262
Silverlight has the Uri.EscapeUriString and Uri.EscapeDataString which can be used to URL-encode portions of a URI such as query strings and path components and such.
Even in the desktop framework, you should never take a dependency on System.Web.dll just for HttpUtility, although many developers still do it. This is bad for 3 reasons.
In addition to the Uri escaping methods described above, if you need HtmlEncode, I would just rip code off that someone else wrote and drop it in your application.
Upvotes: 59