在Windows Phone 7的HttpUtility.UrlEn code? [英] HttpUtility.UrlEncode in Windows Phone 7?

查看:161
本文介绍了在Windows Phone 7的HttpUtility.UrlEn code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

常规的.Net框架包含HttpUtility.UrlEn code在System.Web程序集,并在Silverlight它似乎它被转移到System.Windows.Browser。但是,在Windows Phone 7的(我认为是一样的Silverlight),我似乎无法找到UrlEn code任何一种合适的方式。无论是$ P $的pviously提到组件在Windows Phone 7环境中使用。

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.

推荐答案

Silverlight的有<一个href=\"http://msdn.microsoft.com/en-us/library/system.uri.escapeuristring%28v=VS.95%29.aspx\">Uri.EscapeUriString和<一个href=\"http://msdn.microsoft.com/en-us/library/system.uri.escapedatastring%28v=VS.95%29.aspx\">Uri.EscapeDataString它可以用来网址烯code进行URI的部分,例如查询字符串和路径成分和这样

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.

即使在桌面架构,你不应该承担System.Web.dll程序的依赖只是HttpUtility,虽然不少开发商仍然这样做。这是糟糕的3个原因。

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.


  • 组装非常大,加载它可以显著延迟添加到应用程序。

  • 您会腹胀你的进程的工作集大约20 $ C $行C。

  • 这使得你的应用程序所需要的完整的框架,因为是的System.Web不是在客户端配置文件。

在除了上述,如果你需要HtmlEn code,我只是撕裂code关闭URI转义方法<一href=\"http://$c$c.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/HttpUtility.cs?r=961\">that别人写并砸在你的应用程序。

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.

这篇关于在Windows Phone 7的HttpUtility.UrlEn code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆