I have a handler. When I call it with URL that is to say GET method, it works because I get values with my below handler code.
var encodedUrl = HttpUtility.UrlEncode(context.Request.QueryString.ToString());
How can I get values when I use post method which is below from Handler side:
using (var wb = new WebClient())
{
var data = new NameValueCollection();
data["a"] = "a";
data["b"] = "b";
var response = wb.UploadValues("http://localhost:126/Web", "POST", data);
}
When you receive an http response you basically depend on the "Content Type". Depending on this type is that you read it. Here is a reference on this topic:
For instance if you decide to receive an "application/json" response type. You may be able to use this:
From I can see in your sample it looks like you are trying to implement an "application/x-www-form-urlencoded" and the post needs to be formatted accordingly. Here is a sample for that:
But there are other options available. I hope this is the answer you were looking for.
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.