473,505 Members | 14,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Posting data using HttpWebRequest

I am using the following piece of code to post some data to a web form,

req.Method = "POST";

req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength =formcontents.Length;

sendStream = req.GetRequestStream();

sendStream.Write(formcontents, 0, formcontents.Length);

sendStream.Close();

res = (HttpWebResponse)req.GetResponse();

on last line its continously givng me the following error..

"The remote server returned an error: (500) Internal Server Error."

but the server is my own application, which is working fine, when instead of
giving form contents length i give it hardcoded value it runs fine uptil 7
but after that start giving this error formcontents is a byte[].

Any kind of help will be appreciated.

regards,

Beenish.
Nov 17 '05 #1
1 1166
Beenish Sahar Khan wrote:
I am using the following piece of code to post some data to a web
form,

req.Method = "POST";

req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength =formcontents.Length;

sendStream = req.GetRequestStream();

sendStream.Write(formcontents, 0, formcontents.Length);

sendStream.Close();

res = (HttpWebResponse)req.GetResponse();

on last line its continously givng me the following error..

"The remote server returned an error: (500) Internal Server Error."

but the server is my own application, which is working fine, when
instead of giving form contents length i give it hardcoded value it
runs fine uptil 7 but after that start giving this error formcontents
is a byte[].


Debug your server-side code. It's probably expecting some HTTP header
like User-Agent, which your code does not transmit.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2

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

Similar topics

0
1616
by: someone | last post by:
I am in a situation where I need to package some information from Page1, submit it via POST to another server which will process the information and then send the user to another page on my server...
0
1269
by: Julia | last post by:
Hi,although I am posting use a .NET class I would like to ask you if there is something special need to be done on the ASP side in order to be able to read Hebrew characters from the request when...
1
1570
by: Isaac Martinez | last post by:
Hello all, I have to make a small app that will do the following. 1. Connect to a webserver and get a directory listing. 2. I have to download each file in the specified directory. 3. Once...
1
3169
by: Joey Chömpff | last post by:
Hello, When I'm uploading an file to a JRun WebServer (third party) with a Windows Forms application, l always get an TimeOut while uploading, all other request who doesn't request an post are...
0
1051
by: Jeff Washburn | last post by:
Hi All, I have an HttpWebRequest object that is supposed to post data to a web page. The server is receiving the data, and I am getting an OK response. However, the data is not ending up on...
9
3578
by: buran | last post by:
Dear ASP.NET Programmers, How can I post data to an ASP.NET login page and pass authentication? The login page uses forms authentication, users must supply usernames and password and have to...
7
17258
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
8
3210
by: shankararaman.s | last post by:
Hi, I am trying to develop an interface which will fetch all my Yahoo mails. I am not able to sign in to yahoo by posting the form with my username & password. Please find my code below and...
0
4271
by: msnews.microsoft.com | last post by:
I have been raking my brains on why this does not work. I get back the same login screen again instead of the home page redirection which should occur after a successful login: 'create a cookie...
2
5558
by: adwooley2 | last post by:
Hello. Have been losing plenty of hair over problem whereby I can't make it off the login page. Trying to pass login info to a login page and then move on to another page within the site so that...
0
7098
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
7367
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
7018
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
7471
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
5613
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,...
1
5028
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
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
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 ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.