Windows Phone 7中的HttpUtility.UrlEncode?
【腾讯云】亏本大甩卖,服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!
云产品 配置 价格
服务器 1核2G,带宽5M,系统盘50GB SSD盘,月流量500GB 38元/年
MySQL 1核1G 19元/年
服务器 16核32G,带宽18M,系统盘250GB SSD盘,月流量5000GB 1197元/年
点我进入腾讯云,查看更多详情

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.

#0

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.

#1

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.

#2

Now it is solved. You can use :

Windows.Data.Html.HtmlUtilities.ConvertToText("your_html_string");

推荐文章

分离数据库记录的公共和编辑模式版本

分离数据库记录的公共和编辑模式版本

推荐文章

YUI ajaxFuntion()的JQuery替代方案

YUI ajaxFuntion()的JQuery替代方案

推荐文章

安卓标签问题

安卓标签问题

推荐文章

为我的应用程序映射api?

为我的应用程序映射api?

推荐文章

android应用程序可以在模拟器上运行,但在android手机上运行时速度非常慢

android应用程序可以在模拟器上运行,但在android手机上运行时速度非常慢

推荐文章

防止Silverlight datepicker年份看起来已禁用

防止Silverlight datepicker年份看起来已禁用

推荐文章

如何允许用户在ASP.NET中通过一次上载操作上载多个文件?

如何允许用户在ASP.NET中通过一次上载操作上载多个文件?

推荐文章

使用从Perl调用的程序的结果

使用从Perl调用的程序的结果

推荐文章

Python httplib,urllib语法错误

Python httplib,urllib语法错误

推荐文章

sqlplus中带有remplacement变量的请求之间的联合

sqlplus中带有remplacement变量的请求之间的联合

推荐文章

如何从PHP将指数格式转换为实际数字

如何从PHP将指数格式转换为实际数字

推荐文章

索引后再次输入时间序列数字?

索引后再次输入时间序列数字?

推荐文章

使用Chrome重新选择后退/前进的选择框?

使用Chrome重新选择后退/前进的选择框?

推荐文章

Rails 2.3.5:如何获取路由名称

Rails 2.3.5:如何获取路由名称

推荐文章

创建NSManagedObject派生类时出现问题

创建NSManagedObject派生类时出现问题

推荐文章

start-stop守护进程在命令行工作,但在/etc/init.d脚本中不工作

start-stop守护进程在命令行工作,但在/etc/init.d脚本中不工作