Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
| Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 3rd, 2008, 06:31 PM
Friend of Wrox
 
Join Date: Sep 2007
Location: , , .
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default What is the error message for a 500 server error?

Hi

I have a command line application that gets information from a webpage. My program does some special things if a 404 error or 500 error is returned.

So I made a try and catch to catch these errors however I can't figure out how to simulate a 500 error so I can't see what the error message would if a 500 error was returned.

For instance the 404 returns this "The remote server returned an error: (404) Not Found."

What does a 500 error return.

Here is my code I got.

Code:
string url = CurrentUrl;
            string strResult = "";

            WebResponse objResponse = null;
            WebRequest objRequest = System.Net.HttpWebRequest.Create(url);

            try
            {
                objResponse = objRequest.GetResponse();
                m_tickStart = DateTime.Now;
                StreamReader sr = new StreamReader(objResponse.GetResponseStream());
                strResult = sr.ReadToEnd();
                // Close and clean up the StreamReader
                sr.Close();

            }
            catch (WebException ex)
            {

               strResult =  ex.Message.ToString();
            }


  #2 (permalink)  
Old May 4th, 2008, 03:11 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

500 is an "Internal Server Error". You should be able to mimic that by having something like an uncaught divide by zero error in your code.

--

Joe (Microsoft MVP - XML)


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 500 -- Internal Server Error Vijay Kumar Servlets 2 March 26th, 2007 02:10 AM
ISS 5.1 server error(HTTP 500) r_samy80 BOOK: Beginning ASP 3.0 0 December 18th, 2006 05:23 AM
HTTP 500 - Internal server error helmsly BOOK: Beginning ASP 3.0 11 November 8th, 2006 03:15 AM
HTTP 500: Internal Server Error cyberddindia Classic ASP Databases 4 October 5th, 2006 11:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.