Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo

  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

 
Previous Posts
    - Windows Forms datagrid won't show more than 255 ro...
    - How to create an About Dialog
    - equivalent of a Session variable in Windows Forms?...
    - Webbrowser and Fake filename into the IMG src attr...
    - How to send Crystal Reports report by email
    - Hiding a form's Close ControlBox button
    - How to Deactivate all MDI child forms
    - Typed dataset and the grid control
    - About Events in datagrid and SelectedIndexChanged
    - How to get SQL Server Timestamp value

Archives
    - 10/03/2004 - 10/10/2004
    - 10/10/2004 - 10/17/2004
    - 10/17/2004 - 10/24/2004
    - 10/24/2004 - 10/31/2004
    - 10/31/2004 - 11/07/2004
    - 11/21/2004 - 11/28/2004
    - 11/28/2004 - 12/05/2004
    - 12/05/2004 - 12/12/2004
    - 12/12/2004 - 12/19/2004
    - 12/19/2004 - 12/26/2004
    - 12/26/2004 - 01/02/2005
    - 01/23/2005 - 01/30/2005
    - 01/01/2006 - 01/08/2006
    - 09/24/2006 - 10/01/2006

Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland