简体   繁体   中英

Get raw querystring of WebClient in C#

I'm using a WebClient to make a POST request with a query string but I can't see the raw string. This is what I have:

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;

How can I see the actual raw query string?

WebClient.UploadValues doesn't save the request "raw query string" simply because you provided it with them, and it's not gonna change, thus is redundant.

Furthermore, HttpPost requests doesn't use query string for the request payload, it has a url , a message payload; which is appended after the headers, maybe query string . Thus there is nothing new the client class should let you know, so it won't save it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM