473,657 Members | 2,395 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 = "applicatio n/x-www-form-urlencoded";
req.ContentLeng th =formcontents.L ength;

sendStream = req.GetRequestS tream();

sendStream.Writ e(formcontents, 0, formcontents.Le ngth);

sendStream.Clos e();

res = (HttpWebRespons e)req.GetRespon se();

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 1173
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 = "applicatio n/x-www-form-urlencoded";
req.ContentLeng th =formcontents.L ength;

sendStream = req.GetRequestS tream();

sendStream.Writ e(formcontents, 0, formcontents.Le ngth);

sendStream.Clos e();

res = (HttpWebRespons e)req.GetRespon se();

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.d e
Nov 17 '05 #2

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

Similar topics

0
1630
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 (Page2). I have looked at HttpWebRequest (see code below) on numerous coding websites but have not found a method that works. Does anyone have a solution for this or has seen an example that works for this situation?
0
1299
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 debugging fro Interdev I get gibberish here is my problem I am calling an ASP page from a NET application,and it seems that the hebrew characters are being lost
1
1575
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 the file is downloaded, enter the data into a SQL2k database. 4. After the file is parsed, I have to delete the file. I was able to successfully complete steps 1-3 using the
1
3175
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 going ok? Why? I've tried almost everything. I also tried the KB888528 solution but this also doesn't work. What can the KB887563 do for me? Machine( tried on Windows 2003 Server & WinXp)
0
1064
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 the server. I put a test on the server, and it shows that a hit is being made, but that is all. Here is the code I am using:
9
3583
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 click on a submit button. I want to automate this process by supplying values with HttpWebRequest and then download a file on the site. I think that I cannot invoke the submit button. Pleeeasee help, thanks in advance
7
17291
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 to get it to work in Visual Basic. I tried coding it once myself from scratch and then modified a class that I found on a newsgroup (referenced below). Both seem to be doing the same thing and neither works (or rather, they seem to work but the...
8
3222
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 correct me where am going wrong. string result; System.Net.HttpWebRequest request,request1; System.Net.HttpWebResponse response,response1;
0
4275
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 container so it can be shared between requests so that authentication can be maintained Dim objCookieCont As New CookieContainer 'create request to get the __VIEWSTATE of Authorize.NET's Logon.aspx page
2
5563
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 I can download some data, but I keep getting the login page. Any ideas on this? Here's the code: ================================================== Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
0
8826
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
8503
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
8605
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...
0
7330
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
6166
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
5632
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();...
1
2726
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
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
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.