2016-12-15 63 views
0

我正在使用WebClient使用查詢字符串發出POST請求,但我看不到原始字符串。這是我有:在C中獲取WebClient的原始查詢字符串#

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; 

我怎樣才能看到實際的原始查詢字符串?

感謝

回答

2

WebClient.UploadValues不保存請求「原始查詢字符串」僅僅是因爲你與他們提供它,它不會改變,因此是多餘的。

此外,HttpPost請求不使用查詢字符串的請求有效載荷,它有一個URL,消息有效載荷;後面追加標題,可能是查詢字符串。因此客戶類應該讓你知道什麼新東西,所以它不會保存它。

+0

明白了,弄糊塗了一個GET請求。 – frenchie

相關問題