Answer the question
In order to leave comments, you need to log in
How to disable encode in WebClient UploadValues?
using (var wb = new WebClient())
{
wb.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
var response = wb.UploadValues(url, "POST", data);
responseInString = Encoding.UTF8.GetString(response);
}
Answer the question
In order to leave comments, you need to log in
If the parameter is in Url , then you can instantiate the Uri and disable encoding:
var url = new Uri("http://site.com/index.php?199|¶m=1", true);
// ...
var response = wb.UploadValues(url, "POST", data);
using (var client = new HttpClient())
{
var url = new Uri("http://site.com/index.php?199|¶m=1", true);
var data = new StringBuilder();
data.AppendLine("abc=199|");
using (var content = new StringContent(data.ToString(), Encoding.UTF8, "application/x-www-form-urlencoded"))
{
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
{
request.Content = content;
using (var response = client.SendAsync(request).Result)
{
response.EnsureSuccessStatusCode();
// var result = await response.Content.ReadAsStringAsync();
var result = response.Content.ReadAsStringAsync().Result;
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question