HTTP POST

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to do an http post to a url and include the name/value pairs for the
fields in the form. The WebClient class lets me do this with the
UploadValues method but I need to use a timeout as well, which is contained
in the WebRequest and WebResponse classes. Does anyone know how to get the
HTML from a post with fields while, at the same time, limiting the time
you'll allow for it to complete?
 
to rewrite upoload values is trival, so that you can use WebRequest

air code:

void UploadValues(WebRequest wr, NameValueCollection values)
{
wr.ContentType = "application/x-www-form-urlencoded";
string sep = "";
for (int i=0; i < values.Count; ++i)
{
string s = string.Format("{0}{1}={2}",
sep,
HttpUtility.UrlEncode(values.GetKey(i)),
HttpUtility.UrlEncode(values.Get(i)));
sep = "&";
byte[] buffer = Encoding.ACII.GetBytes(s);
wr.GetRequestStream().Write(buffer,0,buffer.Length);
}
}

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top