473,508 Members | 4,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Novice Question About Webclient

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))

Jan 11 '06 #1
3 1120
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" <xy*@abcde.com> wrote in message
news:uj**************@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))

Jan 11 '06 #2
Done that too - used regular expressions.
"Flashster" <xy*@abcde.com> wrote in message
news:eY**************@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" <xy*@abcde.com> wrote in message
news:uj**************@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))


Jan 11 '06 #3
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

--
Programming 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" <xy*@abcde.com> schreef in bericht
news:uF**************@TK2MSFTNGP10.phx.gbl...
Done that too - used regular expressions.
"Flashster" <xy*@abcde.com> wrote in message
news:eY**************@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" <xy*@abcde.com> wrote in message
news:uj**************@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))



Jan 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6187
by: Seymen Ertas | last post by:
Hi, I don't know if this is the correct place to post this but i am having a little problem with the OpenRead function of the WebClient. Below is the code i am trying to get it to work: ...
11
942
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
2
5350
by: xzzy | last post by:
I have .net 1.1 c# . . . . . using System.Net only lists sockets what do I need to do to be able to do: using System.Net.WebClient;
6
13251
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
6
22028
by: Giovanni | last post by:
Hi Guys, Really strange problem I am experiencing... I have setup a virtual directory with Read Only permissions on an ISA/IIS server (SBS 2003). In that virt. dir., I placed 1 file...
1
6280
by: vin.dor | last post by:
Dear All, I am using WebClient in my Visual Studio .Net 2003 project to download an image from the Internet. The following is my function: C# Code: public static bool downloadFile(string...
1
6462
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
1
12461
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
2
10130
by: MichaelSchoeler | last post by:
Hi, I'm having problems with the WebClient class regarding UTF-8 encoded data. When I access a specific webservice directly I can see the data arrives in corretly formatted UTF-8. But when I...
0
7228
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7058
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.