编码我的字符串通过c#发送http请求
本文关键字:发送 http 请求 我的 字符串 编码 | 更新日期: 2023-09-27 18:13:05
我想发送一个简单的HTTP请求:
var client = new WebClient();
string myString="this is the string i want to send";
message = client.DownloadString("http://www.viralheat.com/api/sentiment/review.xml?text=" + myString + "&api_key="+currentKey);
但是我发送的一些字符串包含#或&或这样的字符,所以我想在发送它之前先对字符串进行编码,因为如果它包含这些特殊字符而不进行编码,则会抛出错误。
Call Uri.EscapeDataString
.
与HttpUtility
不同,这也适用于客户端配置文件。
使用 httutility。UrlEncode