By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,193 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,193 IT Pros & Developers. It's quick & easy.

HTTPWebRequest - better server error handling

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.