473,803 Members | 2,038 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(C ontrolChars.Cr + "Please enter the URI to post data to{for
example, http://www.contoso.com } : ")

uriString = Console.ReadLin e()

' Create a new WebClient instance.

Dim myWebClient As New WebClient

Console.WriteLi ne(ControlChars .Cr + "Please enter the data to be posted to
the URI {0}:", uriString)

Dim postData As String = Console.ReadLin e()

myWebClient.Hea ders.Add("Conte nt-Type", "applicatio n/x-www-form-urlencoded")

' Apply ASCII Encoding to obtain the string as a byte array.

Dim byteArray As Byte() = Encoding.ASCII. GetBytes(postDa ta)

Console.WriteLi ne("Uploading to {0} ...", uriString)

' Upload the input string using the HTTP 1.0 POST method.

Dim responseArray As Byte() = myWebClient.Upl oadData(uriStri ng, "POST",
byteArray)

' Decode and display the response.

Console.WriteLi ne(ControlChars .Cr + "Response received was :{0}",
Encoding.ASCII. GetString(respo nseArray))

Jan 11 '06 #1
3 1133
Its ok - worked it out. I wasn't naming the input fields so the form was
getting confused....rat her like me.

Now I just need to work out how to grab the data out of the HTML .....

"Flashster" <xy*@abcde.co m> wrote in message
news:uj******** ******@tk2msftn gp13.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(C ontrolChars.Cr + "Please enter the URI to post data to{for
example, http://www.contoso.com } : ")

uriString = Console.ReadLin e()

' Create a new WebClient instance.

Dim myWebClient As New WebClient

Console.WriteLi ne(ControlChars .Cr + "Please enter the data to be posted to
the URI {0}:", uriString)

Dim postData As String = Console.ReadLin e()

myWebClient.Hea ders.Add("Conte nt-Type",
"applicatio n/x-www-form-urlencoded")

' Apply ASCII Encoding to obtain the string as a byte array.

Dim byteArray As Byte() = Encoding.ASCII. GetBytes(postDa ta)

Console.WriteLi ne("Uploading to {0} ...", uriString)

' Upload the input string using the HTTP 1.0 POST method.

Dim responseArray As Byte() = myWebClient.Upl oadData(uriStri ng, "POST",
byteArray)

' Decode and display the response.

Console.WriteLi ne(ControlChars .Cr + "Response received was :{0}",
Encoding.ASCII. GetString(respo nseArray))

Jan 11 '06 #2
Done that too - used regular expressions.
"Flashster" <xy*@abcde.co m> wrote in message
news:eY******** ******@TK2MSFTN GP15.phx.gbl...
Its ok - worked it out. I wasn't naming the input fields so the form was
getting confused....rat her like me.

Now I just need to work out how to grab the data out of the HTML .....

"Flashster" <xy*@abcde.co m> wrote in message
news:uj******** ******@tk2msftn gp13.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(C ontrolChars.Cr + "Please enter the URI to post data to{for
example, http://www.contoso.com } : ")

uriString = Console.ReadLin e()

' Create a new WebClient instance.

Dim myWebClient As New WebClient

Console.WriteLi ne(ControlChars .Cr + "Please enter the data to be posted
to the URI {0}:", uriString)

Dim postData As String = Console.ReadLin e()

myWebClient.Hea ders.Add("Conte nt-Type",
"applicatio n/x-www-form-urlencoded")

' Apply ASCII Encoding to obtain the string as a byte array.

Dim byteArray As Byte() = Encoding.ASCII. GetBytes(postDa ta)

Console.WriteLi ne("Uploading to {0} ...", uriString)

' Upload the input string using the HTTP 1.0 POST method.

Dim responseArray As Byte() = myWebClient.Upl oadData(uriStri ng, "POST",
byteArray)

' Decode and display the response.

Console.WriteLi ne(ControlChars .Cr + "Response received was :{0}",
Encoding.ASCII. GetString(respo nseArray))


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.co m> schreef in bericht
news:uF******** ******@TK2MSFTN GP10.phx.gbl...
Done that too - used regular expressions.
"Flashster" <xy*@abcde.co m> wrote in message
news:eY******** ******@TK2MSFTN GP15.phx.gbl...
Its ok - worked it out. I wasn't naming the input fields so the form was
getting confused....rat her like me.

Now I just need to work out how to grab the data out of the HTML .....

"Flashster" <xy*@abcde.co m> wrote in message
news:uj******** ******@tk2msftn gp13.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(C ontrolChars.Cr + "Please enter the URI to post data to{for example, http://www.contoso.com } : ")

uriString = Console.ReadLin e()

' Create a new WebClient instance.

Dim myWebClient As New WebClient

Console.WriteLi ne(ControlChars .Cr + "Please enter the data to be posted
to the URI {0}:", uriString)

Dim postData As String = Console.ReadLin e()

myWebClient.Hea ders.Add("Conte nt-Type",
"applicatio n/x-www-form-urlencoded")

' Apply ASCII Encoding to obtain the string as a byte array.

Dim byteArray As Byte() = Encoding.ASCII. GetBytes(postDa ta)

Console.WriteLi ne("Uploading to {0} ...", uriString)

' Upload the input string using the HTTP 1.0 POST method.

Dim responseArray As Byte() = myWebClient.Upl oadData(uriStri ng, "POST",
byteArray)

' Decode and display the response.

Console.WriteLi ne(ControlChars .Cr + "Response received was :{0}",
Encoding.ASCII. GetString(respo nseArray))



Jan 11 '06 #4

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

Similar topics

5
6226
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: WebClient Client = new WebClient(); Stream strm = Client.OpenRead("http://something.jsp?user=username");
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 during a webclient request" .._Hresult = "-2146233079" .._COMPlusExceptionCode ="-532459699" Sorry I don't have the whole error, but this seems to be the only pertinent
2
5370
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
13305
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 = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileID.ToString() + ".pdf");
6
22108
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 (setup.exe). I then use WebClient.DownloadFileAsync (.NET 2.0 Pro.) and all downloads well including progress bar indicator, bytes received, etc... Here is the problem: When I replace the file (setup.exe), with a different, larger file, it still...
1
6293
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 URL, ref string fileName) { bool result = true;
1
6497
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 <authentication mode="Windows" /> and set up IIS to not allow anonymous access. My browser is set up to auto detect the proxy server, so IE/Firefox can access outside pages, so I added code to auto-detect the proxy server.
1
12507
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 System.Net.WebClient; $WebClient.Encoding = ::Default; $WebClient.Proxy = ::DefaultWebProxy; $WebClient.Proxy.Credentials = ::DefaultCredentials;
2
10176
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 try to pull data from the same webservice url through the WebClient class I get partly garbled UTF-8 data in return. Only some UTF-8 chars (double byte pairs) seems to be corrupted. // Does not work WebClient wc = new WebClient(); string...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10289
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6840
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2968
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.