473,890 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebRequest/WebResponse OR WebClient problem

Hello, everyone.

I am stuck with the following:
There is a webpage which contains a webform, which
contains text fields, and submits the data from current
page to another one.

I need to submit the same data to a webpage from a
Windows Form.

I am playing with WebClient's UploadValues(.. .) method

I've also tried
HttpWebRequest
wrq=(HttpWebReq uest)WebRequest .Create("http://localhost/mail.php");
<some code here>
And then HttpWebResponse wrs=(HttpWebRes ponse)wrq.GetRe sponse();

Nothing. I've tried that on my webserver, and it throws an exception with
error 403 from the
server, FORBIDDEN.

localhost/sendmail.php contains:
<form name="f1" action="mail.ph p" method="post">
<table>
<tr>
<td align="left" valign="top">
Your name:
</td>
<td align="left" valign="top">
<input type="text" name="sender" size="50">
</td>
</tr>
etc............ .....OTHER TEXT FIELDS
<tr>
<td align="left" valign="top">
<input type="submit" value="Send email">
</td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
</table>
</form>

localhost/mail.php receives POST'ed data from localhost/sendmail.php and
imails it me
(basically to prevent people/webrobots from seeing my email, so that I don't
get spam).
Works just fine.

But I need to submit (POST) data from a Windows form.
Thanks.
Any help is appreciated.

Regards, Nurchi
Nov 17 '05 #1
1 2619
Nurchi,

Are you making sure that you are passing the appropriate credentials as
well as cookies (stored locally as well as any that are set by the initial
download of the page)? Web applications more often than not depend heavily
on cookie state to be set correctly, as well as credential information to be
set in order to produce the desired result. When using the
HttpWebRequest/HttpWebResponse or the WebClient classes, you have to make
sure that you are setting things like the cookies, the user agent (web
applications will make decisions on what is rendered, and possibly other
pertinent information is sent back based on this), etc, etc.

In the end, make sure you are going through the appropriate steps
(loading the first page, collecting cookies, then following through to the
next page where you submit the information, etc, etc), as you use these
classes.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Nurchi BECHED" <nu****@telus.n et> wrote in message
news:ZqaVe.2254 49$9A2.63735@ed tnps89...
Hello, everyone.

I am stuck with the following:
There is a webpage which contains a webform, which
contains text fields, and submits the data from current
page to another one.

I need to submit the same data to a webpage from a
Windows Form.

I am playing with WebClient's UploadValues(.. .) method

I've also tried
HttpWebRequest
wrq=(HttpWebReq uest)WebRequest .Create("http://localhost/mail.php");
<some code here>
And then HttpWebResponse wrs=(HttpWebRes ponse)wrq.GetRe sponse();

Nothing. I've tried that on my webserver, and it throws an exception with
error 403 from the
server, FORBIDDEN.

localhost/sendmail.php contains:
<form name="f1" action="mail.ph p" method="post">
<table>
<tr>
<td align="left" valign="top">
Your name:
</td>
<td align="left" valign="top">
<input type="text" name="sender" size="50">
</td>
</tr>
etc............ .....OTHER TEXT FIELDS
<tr>
<td align="left" valign="top">
<input type="submit" value="Send email">
</td>
<td align="left" valign="top">
&nbsp;
</td>
</tr>
</table>
</form>

localhost/mail.php receives POST'ed data from localhost/sendmail.php and
imails it me
(basically to prevent people/webrobots from seeing my email, so that I
don't get spam).
Works just fine.

But I need to submit (POST) data from a Windows form.
Thanks.
Any help is appreciated.

Regards, Nurchi

Nov 17 '05 #2

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

Similar topics

0
1285
by: omyek | last post by:
I'm essentially trying to do what a lot of users seem to want when using the above classes, and that's POST to a webpage. Well, I'm golden when it comes to POSTing, I've been able to post to websites using both the webrequest/response and webclient methods. However, the problem I'm running into with both options is I seem to "lose" my connection/session. Let me try to explain a little better. I connect to a website which
1
1454
by: umeshayk | last post by:
Respected Sir What ever you have explained on WebRequest and WebResponse I came to know very well.I started to implement a project based on this concept.What i did was 1. I used Webrequest to hit the starting page of the website to get the Cookie value(www.ichotelsgroup.com) (I am getting Cookie Value = "JSESSIONID=Q1FXQVIIYWOVPLAQ5U0SJ0VMCD4VOIY4 ; domain=.ichotelsgroup.com; path=/") 2.Then I used WebClient to upload values to Next...
12
2876
by: ThyRock | last post by:
I am working on a WebRequest accessing the US Postal Service WebTools test API. This service uses a DLL file (ShippingAPITest.dll) with a query string which includes XML. The web service accepts the query string with no url encoding. I must pass the <> characters as they are in the query string. If these characters are url encoded the service rejects the request. This API Url is http://testing.shippingapis.com/ShippingAPITest.dll
0
2223
by: Gordon | last post by:
I use the following code to get source HTML. The second line seems to work when I get no response from a site. However, I want to stop the request if it's taking more than 20 - 30 seconds. I can't seem to make it work. Please point out the mistakes that I have. Thanks code............. WebRequest = WebRequest.Create(URL) WebRequest.Timeout() = RunInfo.ConnectTimeout WebResponse = WebRequest.GetResponse 'WEBRESPONSE IS A PUBLIC OBJECT...
6
12489
by: Jensen Bredhal | last post by:
Hello, I need to send command to a web server from a method. I understand this should be possible using the WebClient or WebRequest class. how can this be done? below an example of my HTTP based command to the server:
5
3471
by: james.dixon | last post by:
Hi I have been struggling with what should be a simple thing. I want to crawl the web for specific links, and save any html and files that meet my criteria to my hard drive. I thought that WebRequest/WebResponse would be the best way to go, using a proxy. The page that I am returned is just a proxy generated file, and not the source code. Is there any way around this?
1
4784
by: David Satz | last post by:
Hello--I just upgraded to Visual Studio .NET 2005 and suddenly, all my .NET 1.1 applications that accessed Web sites have broken. For example, this code: WebClient wc = new WebClient(); wc.DownloadFile("http://www.microsoft.com/", "MSFT.htm"); .... throws a WebException on the second line. The WebException doesn't specify a problem, but it has an InnerException of type NullReferenceException with the following stack trace:
1
2690
by: Christian Urbanczyk | last post by:
Hello! I have a problem with the Webrequest. I've search everywhere to find an answer but it seems that no one has the the problem before. So i hope somebody can help me here! Following Code: _________________________________________ WebRequest wrq = WebRequest.Create(URL); WebResponse wrs = wrq.GetResponse();
2
5983
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an application to download images using System.NET classes (webclient, webrequest) asynchronously behind proxy server. The reading method works like this: System.Net.WebClient client=new System.Net.WebClient();
0
9822
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,...
0
11232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10923
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
10462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8016
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
7169
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
5851
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6045
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3277
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.