HttpUtility.UrlEncode in Windows Phone 7?

前端 未结 3 654
旧巷少年郎
旧巷少年郎 2020-12-01 13:57

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 Pho

相关标签:
3条回答
  • 2020-12-01 14:14

    Now it is solved. You can use :

    Windows.Data.Html.HtmlUtilities.ConvertToText("your_html_string");
    
    0 讨论(0)
  • 2020-12-01 14:23

    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.

    • The assembly is very large and loading it can add significant delays to your application.
    • You will be bloating the working set of your process for about 20 lines of code.
    • It makes your application require the full framework since System.Web is not in the client profile.

    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.

    0 讨论(0)
  • 2020-12-01 14:23

    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.

    0 讨论(0)
提交回复
热议问题