473,783 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3027
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****@horkmai l.com> wrote in message
news:Xn******** *************** ********@207.21 7.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****@horkmai l.com> wrote in message
news:Xn******** *************** ********@207.21 7.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.supe rnews.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
19361
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 able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
16
12647
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 MSHTML objects to really load the HTML and request all of the images on site? string lcUrl = http://www.cnn.com; // *** Establish the request
1
2803
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 in a variable and make the request again with that cookie as a header value (Digest Authentication). But, the problem we are facing is: That the HttpWebRequest is getting two responses simultaneously, which means that the code should wait after the...
3
9904
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 connect to the remote server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
0
262
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 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.
0
1562
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 being thrown when getting the response from a specific host. I'm pretty sure the framework's implementation doesn't like the formating or status code of the returned response header. It throws the exception without giving me a way of handling it...
0
12790
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 problem. I'm using this code in a ASP.NET 2.0 application just in case that matters, maybe someone knows a better way to do this?
2
5683
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. This worked fine in a .NET 1.1 project. I have copied the same Mailhandler class into a .NET 2.0 project. This, too, worked fine when I initially tested it, running as a Windows Forms app on my machine (running under my network account). ...
2
3487
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 HttpWebRequest object. Under normal circumstances I am able to use the webservice without any problems. But after using an HttpWebRequest object to make a call to a website all subsequent attempts to use the WebService will fail with a 401...
0
10313
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
10081
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
8968
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
7494
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
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.