[英]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.