Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #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)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.