如何在不使用的System.Web你UrlEn code? [英] How do you UrlEncode without using System.Web?

查看:304
本文介绍了如何在不使用的System.Web你UrlEn code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个调用的Web网站数据的Windows客户端应用程序。为了使安装到最低限度,我只是想用的dll在.NET Framework客户端配置文件 。麻烦的是,我需要UrlEn $ C C一些参数$,有一个简单的方法来做到这一点,而不用导入System.Web.dll中这不是客户端Pofile?

I am trying to write a windows client application that calls a web site for data. To keep the install to a minimum I am trying only use dlls in the .NET Framework Client Profile. Trouble is that I need to UrlEncode some parameters, is there an easy way to do this without importing System.Web.dll which is not part of the Client Pofile?

推荐答案

System.Uri.EscapeUriString()是有问题的某些人物,对我来说这是一个数字/磅的#号在字符串中的

System.Uri.EscapeUriString() can be problematic with certain characters, for me it was a number / pound '#' sign in the string.

如果这是你的问题,试试:

If that is an issue for you, try:

System.Uri.EscapeDataString() //Works excellent with individual values

相反。

下面是一个太问题的答案,解释的区别:

Here is a SO question answer that explains the difference:

<一个href="http://stackoverflow.com/questions/4396598/whats-the-difference-between-escapeuristring-and-escapedatastring">what's EscapeUriString之间的差和EscapeDataString 的

这篇关于如何在不使用的System.Web你UrlEn code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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