I need a very simple HttpWebRequest Post example in ASP.NET c#..

I have many examples that do screen scrapes and return content as XML and such, BUT I don't need to get any kind of response.  I want the code to be very simple and in as few files of code as possible.

All I have to do is a pass three parameters to a web service via HTTP.

Who can give me an example?  Thanks!
Who is Participating?
kaylanreilorConnect With a Mentor Commented:
But when the guy writes something like this, it should match what's you're looking for :
byte[]  buffer = Encoding.ASCII.GetBytes(strBuffer);
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(strPage);
WebReq.Method = "POST";
WebReq.ContentType ="application/x-www-form-urlencoded";
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);

Open in new window

sggexchangeAuthor Commented:
These examples do work, but they are pretty much the same thing I've seen before.  I do not need ANY response from the webserver at all, so do I have to use a WebResponse object at all?  I guess I'm just trying to do it with less code.
sggexchangeAuthor Commented:
that works...missed that bit the first time.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.