|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Novice Question About WebclientI want to (if its possible) post information to a web based form from my windows form app and receive the resulting data from the web page. The web forms code appears to be in javascript (not sure if that is relevent). I have tried, as a test, using the example code (see below), but the only data I get back is the actual web page the data is on, without the resulting data (as if the page is just reloading). Is this something I am doing wrong (likely) or prehaps a restriction of the web site not allowing remote submittions? The web form itself only requires a single field to be input. The code I have tried: Dim uriString As String Console.Write(ControlChars.Cr + "Please enter the URI to post data to{for example, http://www.contoso.com} : ") uriString = Console.ReadLine() ' Create a new WebClient instance. Dim myWebClient As New WebClient Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the URI {0}:", uriString) Dim postData As String = Console.ReadLine() myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded") ' Apply ASCII Encoding to obtain the string as a byte array. Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData) Console.WriteLine("Uploading to {0} ...", uriString) ' Upload the input string using the HTTP 1.0 POST method. Dim responseArray As Byte() = myWebClient.UploadData(uriString, "POST", byteArray) ' Decode and display the response. Console.WriteLine(ControlChars.Cr + "Response received was :{0}", Encoding.ASCII.GetString(responseArray)) Its ok - worked it out. I wasn't naming the input fields so the form was
getting confused....rather like me. Now I just need to work out how to grab the data out of the HTML ..... Show quoteHide quote "Flashster" <x**@abcde.com> wrote in message news:ujFyjrqFGHA.3728@tk2msftngp13.phx.gbl... > I'm a beginner so please be gentle..... > > I want to (if its possible) post information to a web based form from my > windows form app and receive the resulting data from the web page. > > The web forms code appears to be in javascript (not sure if that is > relevent). > > I have tried, as a test, using the example code (see below), but the only > data I get back is the actual web page the data is on, without the > resulting data (as if the page is just reloading). Is this something I am > doing wrong (likely) or prehaps a restriction of the web site not allowing > remote submittions? The web form itself only requires a single field to be > input. > > > The code I have tried: > > Dim uriString As String > > Console.Write(ControlChars.Cr + "Please enter the URI to post data to{for > example, http://www.contoso.com} : ") > > uriString = Console.ReadLine() > > ' Create a new WebClient instance. > > Dim myWebClient As New WebClient > > Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to > the URI {0}:", uriString) > > Dim postData As String = Console.ReadLine() > > myWebClient.Headers.Add("Content-Type", > "application/x-www-form-urlencoded") > > ' Apply ASCII Encoding to obtain the string as a byte array. > > Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData) > > Console.WriteLine("Uploading to {0} ...", uriString) > > ' Upload the input string using the HTTP 1.0 POST method. > > Dim responseArray As Byte() = myWebClient.UploadData(uriString, "POST", > byteArray) > > ' Decode and display the response. > > Console.WriteLine(ControlChars.Cr + "Response received was :{0}", > Encoding.ASCII.GetString(responseArray)) > > > Done that too - used regular expressions.
Show quoteHide quote "Flashster" <x**@abcde.com> wrote in message news:eYWEp0qFGHA.2704@TK2MSFTNGP15.phx.gbl... > Its ok - worked it out. I wasn't naming the input fields so the form was > getting confused....rather like me. > > Now I just need to work out how to grab the data out of the HTML ..... > > > > "Flashster" <x**@abcde.com> wrote in message > news:ujFyjrqFGHA.3728@tk2msftngp13.phx.gbl... >> I'm a beginner so please be gentle..... >> >> I want to (if its possible) post information to a web based form from my >> windows form app and receive the resulting data from the web page. >> >> The web forms code appears to be in javascript (not sure if that is >> relevent). >> >> I have tried, as a test, using the example code (see below), but the only >> data I get back is the actual web page the data is on, without the >> resulting data (as if the page is just reloading). Is this something I am >> doing wrong (likely) or prehaps a restriction of the web site not >> allowing remote submittions? The web form itself only requires a single >> field to be input. >> >> >> The code I have tried: >> >> Dim uriString As String >> >> Console.Write(ControlChars.Cr + "Please enter the URI to post data to{for >> example, http://www.contoso.com} : ") >> >> uriString = Console.ReadLine() >> >> ' Create a new WebClient instance. >> >> Dim myWebClient As New WebClient >> >> Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted >> to the URI {0}:", uriString) >> >> Dim postData As String = Console.ReadLine() >> >> myWebClient.Headers.Add("Content-Type", >> "application/x-www-form-urlencoded") >> >> ' Apply ASCII Encoding to obtain the string as a byte array. >> >> Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData) >> >> Console.WriteLine("Uploading to {0} ...", uriString) >> >> ' Upload the input string using the HTTP 1.0 POST method. >> >> Dim responseArray As Byte() = myWebClient.UploadData(uriString, "POST", >> byteArray) >> >> ' Decode and display the response. >> >> Console.WriteLine(ControlChars.Cr + "Response received was :{0}", >> Encoding.ASCII.GetString(responseArray)) >> >> >> > > Hi, good you found the answer. But maybe you can post some sample code, so
that anyone else who ever needs it doesn't get to "frustrated" when he/she starts searching google and finds your post and then thinks he has found his answer only to realize when he reads the post it doesn't help him out. The ng thanks you in advance :-) Greetz Peter -- Show quoteHide quoteProgramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook) "Flashster" <x**@abcde.com> schreef in bericht news:uFdUbPrFGHA.3900@TK2MSFTNGP10.phx.gbl... > Done that too - used regular expressions. > > > "Flashster" <x**@abcde.com> wrote in message > news:eYWEp0qFGHA.2704@TK2MSFTNGP15.phx.gbl... > > Its ok - worked it out. I wasn't naming the input fields so the form was > > getting confused....rather like me. > > > > Now I just need to work out how to grab the data out of the HTML ..... > > > > > > > > "Flashster" <x**@abcde.com> wrote in message > > news:ujFyjrqFGHA.3728@tk2msftngp13.phx.gbl... > >> I'm a beginner so please be gentle..... > >> > >> I want to (if its possible) post information to a web based form from my > >> windows form app and receive the resulting data from the web page. > >> > >> The web forms code appears to be in javascript (not sure if that is > >> relevent). > >> > >> I have tried, as a test, using the example code (see below), but the only > >> data I get back is the actual web page the data is on, without the > >> resulting data (as if the page is just reloading). Is this something I am > >> doing wrong (likely) or prehaps a restriction of the web site not > >> allowing remote submittions? The web form itself only requires a single > >> field to be input. > >> > >> > >> The code I have tried: > >> > >> Dim uriString As String > >> > >> Console.Write(ControlChars.Cr + "Please enter the URI to post data to{for > >> example, http://www.contoso.com} : ") > >> > >> uriString = Console.ReadLine() > >> > >> ' Create a new WebClient instance. > >> > >> Dim myWebClient As New WebClient > >> > >> Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted > >> to the URI {0}:", uriString) > >> > >> Dim postData As String = Console.ReadLine() > >> > >> myWebClient.Headers.Add("Content-Type", > >> "application/x-www-form-urlencoded") > >> > >> ' Apply ASCII Encoding to obtain the string as a byte array. > >> > >> Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData) > >> > >> Console.WriteLine("Uploading to {0} ...", uriString) > >> > >> ' Upload the input string using the HTTP 1.0 POST method. > >> > >> Dim responseArray As Byte() = myWebClient.UploadData(uriString, "POST", > >> byteArray) > >> > >> ' Decode and display the response. > >> > >> Console.WriteLine(ControlChars.Cr + "Response received was :{0}", > >> Encoding.ASCII.GetString(responseArray)) > >> > >> > >> > > > > > >
Inheritance
What happened to the Class view in VS2005? Drag and Drop to SysTray ? VB 2005 - How to hook into Windows to intercept all mouse events? Hide Window form (top most) Handling Events in VB.Net A place to discuss future vb featuresause? Menu is disapearing in 2005 Crystal 11 & .NET 2003 uint32 conversion on win32_pingstatus |
|||||||||||||||||||||||