c# - 你如何在不使用 System.Web 的情况下进行 UrlEncode?

标签 c# .net urlencode .net-client-profile

我正在尝试编写一个调用网站获取数据的 Windows 客户端应用程序。为了尽量减少安装,我只尝试使用 dlls in the .NET Framework Client Profile .问题是我需要对一些参数进行 UrlEncode,有没有一种简单的方法可以在不导入不属于客户端 Pofile 的 System.Web.dll 的情况下执行此操作?

最佳答案

System.Uri.EscapeUriString() 某些字符可能会有问题,对我来说,它是字符串中的数字/井号“#”。

如果这对您来说是个问题,请尝试:

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

这是解释差异的 SO 问题答案:

What's the difference between EscapeUriString and EscapeDataString?

并建议在任何方面使用 Uri.EscapeDataString()

关于c# - 你如何在不使用 System.Web 的情况下进行 UrlEncode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3840762/

相关文章:

c# - 使用 iTextSharp 获取复选框的导出值

java - Android解析json响应中的特殊字符

c# - IDisposable 字段怎么能在这里为空?

c# - Azure函数: timer trigger and consumption plan issue

.net - 使用不同算法的 UUID 冲突风险

.net - .NET 2.0+ 中的简单事件记录实现

查询字符串参数的 Java URL 编码

javascript - 如何在 node.js 中获取 big5 urlencode?

c# - 通过数据访问层从数据库中获取数据的聪明方法?

.net - 为什么ContinueWith传Task作为参数