Trouble Performing An HTTP POST

R

rh1200la

Hi there. I'm having trouble with an HTTP Post in my code behind. Can
anyone help?

Here's my code:


string data = "&fields_fname = " + txtFirstName.Text + "&fields_lname="
+ txtLastName.Text;
string url = "http://localhost/app/default.asp";

WebRequest objWebRequest = WebRequest.Create(url);
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";

byte[] bytes = System.Text.Encoding.ASCII.GetBytes (data);
objWebRequest.ContentLength = bytes.Length;

Stream outputStream = objWebRequest.GetRequestStream();
outputStream.Write (bytes, 0, bytes.Length);
outputStream.Close ();
 
S

Sean Chambers

Whats the trouble your having with it?

The first thing I notice is that you start your data with a &, you dont
need one in front.

Other than that, whats the problem?

Sean
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top