473,396 Members | 1,895 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,396 software developers and data experts.

HttpWebRequest - check for success?

Hi all,

I'm using the HttpWebRequest class to POST a form to a partner site.
Communication with the "Partner" site admin is shoddy at best and I'm having
a hard time determining if the POST is actually working. I'm not an HTTP
pro, should I expect to see some kind of response after I close the Stream
from GetResponseStream()? Any codes I can check for?

I have been watching the HasResponse property, but it's always false. Don't
know if that's normal or if that means I'm failing.

Here is the code:

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("https://<edited>.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.AllowAutoRedirect = true;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
Any tips appreciated.

Thanks!
Jul 10 '06 #1
1 3530
Call getresponse after you have written data into it. If you get 200 code
back, then it succeeded.

"Steve" <sk**@skle.comwrote in message
news:Ot**************@TK2MSFTNGP03.phx.gbl...
Hi all,

I'm using the HttpWebRequest class to POST a form to a partner site.
Communication with the "Partner" site admin is shoddy at best and I'm
having a hard time determining if the POST is actually working. I'm not
an HTTP pro, should I expect to see some kind of response after I close
the Stream from GetResponseStream()? Any codes I can check for?

I have been watching the HasResponse property, but it's always false.
Don't know if that's normal or if that means I'm failing.

Here is the code:

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("https://<edited>.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.AllowAutoRedirect = true;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
Any tips appreciated.

Thanks!

Jul 10 '06 #2

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

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
2
by: TK | last post by:
I have a trouble to get web resopnse from an aspx page which is secured by Forms Authentication with custom user account database. My client application is a console application but not a browser....
1
by: Deepak | last post by:
We retrieve data from a company called XYZ through httpwebrequest. The program is coded using VB.NET They have given a certificate to install. This certificate is included with the request...
2
by: Maris Janis Vasilevskis | last post by:
Hi, Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does? More details. I port JScript to JScript.NET I have a server (ASP invoking...
6
by: Oliver | last post by:
I have a very wired problem requesting one specific url from within my application. I have struggeled with this for 5 hours now, and searched google withour any luck, so i hope that someone are...
3
by: wavemill | last post by:
Hello! This is my problem: I would like acces to my ebay account with post data. I have a problem with cookie. The registration in the ebay website work well after there is an error" you...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
5
by: Glenn | last post by:
Hi I'm trying to building something to check the availability of a web page. The code is using a HttpWebRequest, bypassing our proxy server and hitting both HTTP/HTTPS pages. Initially I get...
15
by: Nightcrawler | last post by:
I am currently using the HttpWebRequest and HttpWebResponse to pull webpages down from a few urls. string url = "some url"; HttpWebRequest httpWebRequest =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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
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,...

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.