Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

post form data error

Status
Not open for further replies.

teamy

MIS
Mar 8, 2005
3
TR
i am trying to develop an app. that will send form datas to web pages. when I write following expression to browser's adress line it accepts user name and password then redirects me to date.asp.

ex.

Then I try to use that expression as follows but when I read the response stream, i see that it is still the login.asp page (not date.asp).

WebRequest wrq = WebRequest.Create("
WebResponse response = wrq.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader (responseStream);
String res = reader.ReadToEnd ();
textBox1.Text = res;

I also tried to POST data via outputstream as follows:

ASCIIEncoding encoding=new ASCIIEncoding();
string postData= "txtUser=jfa&txtPass=jfa&cmdOK=Submit"
byte[] data = encoding.GetBytes(postData);

string address = "WebRequest wrq = WebRequest.Create(address);
wrq.Method = "POST";
wrq.ContentType = "application/x-wrq.ContentLength = data.Length;

Stream outputStream = wrq.GetRequestStream();
outputStream.Write (data, 0, data.Length);
outputStream.Close ();

//read response

WebResponse response = wrq.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader (responseStream);
String res = reader.ReadToEnd ();
textBox1.Text = res;

but it didn't work again.. Waiting for any idea. thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top