473,413 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

WebClient/POST/aspx file

Hi folks! I tried to post a web form using the WebClient class and
HttpWebRequest/HttpWebResponse. It didn't work for the ASPX web pages. I
always got an unposted version - like if I had just made a simple request
without posting anything. I have written the same thing using the Perl's
LWD::UserAgent class and it was the same. The web form is really very
simple. As soon as I created the ASP file with the same form everything
worked! Does anyone has an explanation? I have Framework 1.0 installed. The
only thing that I think can cause trouble is the viewstate. The code samples
are bellow.

Thanks,

Adnan

<form id="WebForm1" method="post" runat="server">
<%
if (Page.IsPostBack)
{
Response.Write("foobar");
}
%>

<input type="text" name="abc" value="">
<input type="submit" name="foo" value="bar">

</form>

System.Net.WebClient wc = new System.Net.WebClient();
System.Collections.Specialized.NameValueCollection values = new
System.Collections.Specialized.NameValueCollection ();

values.Add("abc", "123");
values.Add("foo", "bar");

byte[] dataBuffer = wc.UploadValues(http://localhost/WebForm1.aspx,"POST",
values);

textBox1.Text = System.Text.Encoding.Default.GetString(dataBuffer) ;

use strict;
use LWP::UserAgent;
use HTTP::Request::Common;

my $ua = new LWP::UserAgent;
my $res = $ua->request(POST "http://localhost/WebForm1.aspx", [foo => "bar",
abc => "123"]);

if ($res->is_success) {
print $res->content;
}
Nov 18 '05 #1
1 2953
I solved my problem after I started a HTTP sniffer. I saw the exact post
data the form was sending and after I copied the name/value pairs and sent
them using the UploadData method everything worked- so now I can
automatically configure some stuff on the firewall using the Web interface
hehe.

Bye,

Adnan
Nov 18 '05 #2

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

Similar topics

6
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 =...
2
by: Jeff Baker | last post by:
How does one post to an ASPX page using the WebClient when the form name is required?
4
by: Grant Harmeyer | last post by:
When I try to upload a file to a resource on my local webserver, my code catches an exception that a 405 error (method not supported) has occured on the server. I set the code up nearly exactly as...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
1
by: Phillip N Rounds | last post by:
I'm having problems using the WebClient.UploadFile() command. I have MySender.ASPX which is supposed to upload two files to the server. There is also ConsumeFileUpload.aspx which is intended to...
1
by: Chris Dunaway | last post by:
I am using the following code to test an .aspx page which has no presentation and only a handler for the Page_Load event. I am using this code to POST the contents of an .xml file to the .aspx...
3
by: =?Utf-8?B?dmFzaW1v?= | last post by:
Have the following code: wkLocalPath = "C:\A\1.jpg" wkServerPath = "http://servername/dirname/1.jpg" wcClient.Credentials = New NetworkCredential("UID", "PW") wcClient.UploadFile(wkServerPath,...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
5
by: benmess | last post by:
This code snippet works fine on a localhost because the file you upload resides on the host machine (where FileServer.aspx is a new page invoked from the UploadFile call) function...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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
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...
0
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...
0
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...

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.