473,586 Members | 2,681 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 2605
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
1275
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...
1
1443
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 =...
12
2852
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...
0
2207
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)...
6
12478
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
3448
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...
1
4750
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...
1
2680
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
5963
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...
0
7912
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...
0
8202
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. ...
0
8216
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...
0
6614
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...
1
5710
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...
0
5390
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...
0
3837
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...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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

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.