Hello,
I would like to know how to post form data programmatically. The idea is
to get the intranet web page, programmatically entre the username and
password in a login form, post it and be redirected to the logged in
page. So far I have found the code to post data in a form, but I am not
sure if this is the correct way to do it.
Thank you in advance
string url = "http://intranet/app";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
string proxy = null;
//string data = String.Format("USER={0}&PASSWORD={1}", "user",
"password");
byte[] buffer = Encoding.UTF8.GetBytes(data);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = buffer.Length;
req.Proxy = new WebProxy(proxy, true); // ignore for local
addresses
req.CookieContainer = new CookieContainer();
Stream reqst = req.GetRequestStream(); // add form data to request
stream
reqst.Write(buffer, 0, buffer.Length);
reqst.Flush();
reqst.Close();
*** Sent via Developersdex http://www.developersdex.com ***