[英]Get raw querystring of WebClient in C#
我正在使用WebClient发出带有查询字符串的POST请求,但看不到原始字符串。 这就是我所拥有的:
WebClient TheWebClient = new WebClient();
TheWebClient.QueryString.Add("Param1", "1234");
TheWebClient.QueryString.Add("Param2", "4567");
TheWebClient.QueryString.Add("Param3", "4539");
var TheResponse = TheWebClient.UploadValues("https://www.example.com/posturl", "POST", TheWebClient.QueryString);
string TheResponseString = TheWebClient.Encoding.GetString(TheResponse);
//problem is that this only shows the keys
var RawQueryString = TheWebClient.QueryString;
如何查看实际的原始查询字符串?
WebClient.UploadValues不会仅仅因为您向请求提供了“原始查询字符串”而保存了请求,并且它不会更改,因此是多余的。
此外, HttpPost请求不使用查询字符串作为请求有效负载,它具有url (消息有效负载)。 附加在标题之后,可能是查询字符串 。 因此,客户端类不会让您知道任何新内容,因此不会保存它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.