
Untitled
By: a guest on
May 21st, 2012 | syntax:
None | size: 0.53 KB | hits: 11 | expires: Never
C# POSTing values from NameValueCollection
public static string Post (string url, NameValueCollection formData)
{
string response;
int length = formData.???
using (WebClient webClient = new WebClient())
{
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
webClient.Headers.Add ("Content-Length", length);
byte[] responseBytes = webClient.UploadValues (url, "POST", formData);
response = Encoding.UTF8.GetString (responseBytes);
}
return response;
}