Hello,
I would like to know how to post form data programmaticall y. The idea is
to get the intranet web page, programmaticall y 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.Cre ate(url);
string proxy = null;
//string data = String.Format(" USER={0}&PASSWO RD={1}", "user",
"password") ;
byte[] buffer = Encoding.UTF8.G etBytes(data);
req.Method = "POST";
req.ContentType = "applicatio n/x-www-form-urlencoded";
req.ContentLeng th = buffer.Length;
req.Proxy = new WebProxy(proxy, true); // ignore for local
addresses
req.CookieConta iner = new CookieContainer ();
Stream reqst = req.GetRequestS tream(); // add form data to request
stream
reqst.Write(buf fer, 0, buffer.Length);
reqst.Flush();
reqst.Close();
*** Sent via Developersdex http://www.developersdex.com ***