how can i post parameters to a web page ?
-
hello all : i wanted send some information to a form that is on the web (http://www.cao.ir/farsi/fids/index.asp), with C# languge i wanted to generate a code on c# that fill this form automatically & give me information after fill & post that but i don't know how can i do it !! i can tell you that i wanted to produced a spider or robot to do it. please guide & help me to find it out hope To hear from u soon Kind Regards
-
hello all : i wanted send some information to a form that is on the web (http://www.cao.ir/farsi/fids/index.asp), with C# languge i wanted to generate a code on c# that fill this form automatically & give me information after fill & post that but i don't know how can i do it !! i can tell you that i wanted to produced a spider or robot to do it. please guide & help me to find it out hope To hear from u soon Kind Regards
You will have to write a class for HTTP Upload. Which can upload data on the given HTTP locaion.
Regards, Amit Kumar HDISM, PGDCA, MCP, MCAD, MCSD amit_chikara2002@hotmail.com
-
hello all : i wanted send some information to a form that is on the web (http://www.cao.ir/farsi/fids/index.asp), with C# languge i wanted to generate a code on c# that fill this form automatically & give me information after fill & post that but i don't know how can i do it !! i can tell you that i wanted to produced a spider or robot to do it. please guide & help me to find it out hope To hear from u soon Kind Regards
-
hello all : i wanted send some information to a form that is on the web (http://www.cao.ir/farsi/fids/index.asp), with C# languge i wanted to generate a code on c# that fill this form automatically & give me information after fill & post that but i don't know how can i do it !! i can tell you that i wanted to produced a spider or robot to do it. please guide & help me to find it out hope To hear from u soon Kind Regards
hello again ... and thank you ok ,i find how declare parameter and post to server ... i find it from this site : http://en.csharp-online.net/index.php?title=HTTP\_Post and here the solve : using System.Net; ... string HttpPost (string uri, string parameters) { // parameters: name1=value1&name2=value2 WebRequest webRequest = WebRequest.Create (uri); //string ProxyString = System.Configuration.ConfigurationManager.AppSettings // [GetConfigKey("proxy")]; //webRequest.Proxy = new WebProxy (ProxyString, true); //Commenting out above required change to App.Config webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Method = "POST"; byte[] bytes = Encoding.ASCII.GetBytes (parameters); Stream os = null; try { // send the Post webRequest.ContentLength = bytes.Length; //Count bytes to send os = webRequest.GetRequestStream(); os.Write (bytes, 0, bytes.Length); //Send it } catch (WebException ex) { MessageBox.Show ( ex.Message, "HttpPost: Request error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } finally { if (os != null) { os.Close(); } } try { // get the response WebResponse webResponse = webRequest.GetResponse(); if (webResponse == null) { return null; } StreamReader sr = new StreamReader (webResponse.GetResponseStream()); return sr.ReadToEnd ().Trim (); } catch (WebException ex) { MessageBox.Show ( ex.Message, "HttpPost: Response error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } return null; } // end HttpPost
-
hello all : i wanted send some information to a form that is on the web (http://www.cao.ir/farsi/fids/index.asp), with C# languge i wanted to generate a code on c# that fill this form automatically & give me information after fill & post that but i don't know how can i do it !! i can tell you that i wanted to produced a spider or robot to do it. please guide & help me to find it out hope To hear from u soon Kind Regards
hello using System.Net; ... string HttpPost (string uri, string parameters) { // parameters: name1=value1&name2=value2 WebRequest webRequest = WebRequest.Create (uri); //string ProxyString = System.Configuration.ConfigurationManager.AppSettings // [GetConfigKey("proxy")]; //webRequest.Proxy = new WebProxy (ProxyString, true); //Commenting out above required change to App.Config webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Method = "POST"; byte[] bytes = Encoding.ASCII.GetBytes (parameters); Stream os = null; try { // send the Post webRequest.ContentLength = bytes.Length; //Count bytes to send os = webRequest.GetRequestStream(); os.Write (bytes, 0, bytes.Length); //Send it } catch (WebException ex) { MessageBox.Show ( ex.Message, "HttpPost: Request error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } finally { if (os != null) { os.Close(); } } try { // get the response WebResponse webResponse = webRequest.GetResponse(); if (webResponse == null) { return null; } StreamReader sr = new StreamReader (webResponse.GetResponseStream()); return sr.ReadToEnd ().Trim (); } catch (WebException ex) { MessageBox.Show ( ex.Message, "HttpPost: Response error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } return null; } // end HttpPost