HTTPWebRequest - better server error handling
(Friday, October 08, 2004)
Found the following interesting discussion in the Newsgroups:
HTTPWebRequest - better server error handling by: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!
| | | Reply: by:steve
| | | 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.
| | | Reply: by: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.
|
|
0 Comments:
Post a Comment