Reputation: 1217
I use HttpWebRequest to upload file on the server. But I also want to send some parameters (I mean name-value pairs)
Upvotes: 0
Views: 746
Reputation: 8946
you can try this:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("some site");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
byte[] data = "some data";
request.ContentLength = data.Length;
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Upvotes: 0
Reputation: 192
You can add them to the query string. They'll be available on the server, regardless of whether the HTTP method is POST or GET.
Upvotes: 1