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.
string url = CurrentUrl;
string strResult = "";
WebResponse objResponse = null;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
m_tickStart = DateTime.Now;
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
strResult = sr.ReadToEnd();
// Close and clean up the StreamReader
catch (WebException ex)
strResult = ex.Message.ToString();