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

HTTPWebRequest - better server error handling

bag
Greetings!
I am currently creating a program that will retrieve information from a
web site based on user input. I have the system working correctly, but
am running into a problem (that I probably should have checked for in
the beginning ;)

Summary:
Using an HTTPRequest, I want to be able to retrieve the page a server
would send with an error (like a custom 404) instead of getting a
WebException.

Detailed:
The user can determine what web page it is going to get data from. The
problem I discovered is that one of my test files has moved - making the
server return a 404.

The problem is, instead of returning the actual data from the server,
I'm getting an exception. Most servers have their own custom 404 pages,
and I would like the user to be able to see that.

Currently, the only solution I can think of is to make a general socket
stream to retrieve the web page and send the data directly (if the web
page is not found), but that will be clumsy and I would rather do it
right than a cruddy workaround.

Is there any other options? Thank you for assistance!
Nov 20 '05 #1
3 2997
if you catch the webexception, the server's content s/b part of the
exception information. i had the same problem when web services being
consumed returned an error 500...the ws was providing specific details about
the error but i was puzzled about how to get the details...they're in the
exception.
"bag" <pu****@horkmail.com> wrote in message
news:Xn*******************************@207.217.125 .205...
| Greetings!
| I am currently creating a program that will retrieve information from a
| web site based on user input. I have the system working correctly, but
| am running into a problem (that I probably should have checked for in
| the beginning ;)
|
| Summary:
| Using an HTTPRequest, I want to be able to retrieve the page a server
| would send with an error (like a custom 404) instead of getting a
| WebException.
|
| Detailed:
| The user can determine what web page it is going to get data from. The
| problem I discovered is that one of my test files has moved - making the
| server return a 404.
|
| The problem is, instead of returning the actual data from the server,
| I'm getting an exception. Most servers have their own custom 404 pages,
| and I would like the user to be able to see that.
|
| Currently, the only solution I can think of is to make a general socket
| stream to retrieve the web page and send the data directly (if the web
| page is not found), but that will be clumsy and I would rather do it
| right than a cruddy workaround.
|
| Is there any other options? Thank you for assistance!
Nov 20 '05 #2
if you catch the webexception, the server's content s/b part of the
exception information. i had the same problem when web services being
consumed returned an error 500...the ws was providing specific details about
the error but i was puzzled about how to get the details...they're in the
exception.
"bag" <pu****@horkmail.com> wrote in message
news:Xn*******************************@207.217.125 .205...
| Greetings!
| I am currently creating a program that will retrieve information from a
| web site based on user input. I have the system working correctly, but
| am running into a problem (that I probably should have checked for in
| the beginning ;)
|
| Summary:
| Using an HTTPRequest, I want to be able to retrieve the page a server
| would send with an error (like a custom 404) instead of getting a
| WebException.
|
| Detailed:
| The user can determine what web page it is going to get data from. The
| problem I discovered is that one of my test files has moved - making the
| server return a 404.
|
| The problem is, instead of returning the actual data from the server,
| I'm getting an exception. Most servers have their own custom 404 pages,
| and I would like the user to be able to see that.
|
| Currently, the only solution I can think of is to make a general socket
| stream to retrieve the web page and send the data directly (if the web
| page is not found), but that will be clumsy and I would rather do it
| right than a cruddy workaround.
|
| Is there any other options? Thank you for assistance!
Nov 20 '05 #3
bag
I added a watch to the webexception and looked all through the data and
could not find the actual server content. Can you give me the specific
location?

Thanks for the help.
"steve" <a@b.com> wrote in news:10*************@corp.supernews.com:
if you catch the webexception, the server's content s/b part of the
exception information. i had the same problem when web services being
consumed returned an error 500...the ws was providing specific details
about the error but i was puzzled about how to get the
details...they're in the exception.

Nov 20 '05 #4

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...
16
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the...
1
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
3
by: Jason | last post by:
I'm having a hard time getting a call to HttpWebRequest's GetRequestSteam to work. Each time I try to run it, I get the following error: The underlying connection was closed: Unable to...
0
by: bag | last post by:
Greetings! I am currently creating a program that will retrieve information from a web site based on user input. I have the system working correctly, but am running into a problem (that I...
0
by: boxboy | last post by:
Hi, I'm writing a console application and am having a problem with HttpWebRequest when posting data to a webserver. A "System.Net.WebException: The server committed a protocol violation" is always...
0
by: barrybevel | last post by:
Hi, I'm trying to login to the www.vodafone.ie website using HttpWebRequest. It works fine with IE/Firefox and the .NET Web Control too, just not with my code. I think it's a redirect 302...
2
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi I have a utility class, called MailHandler, that I wrote to read and operate on emails on an Exchange server using WebDAV. The WebDAV SQL statements are sent using an HttpWebRequest object....
2
by: =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post by:
Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0. This problem can be shown when trying to access a WebService using SSL and through a proxy server after using the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.