Home > Uncategorized > Getting more out of your 500 Internal Server Error

Getting more out of your 500 Internal Server Error

When you make a request from .NET to a remote page, and that page crashes with a 500 error. the exception thrown doesn’t normally tell you anything more than a 500 server error has occurred. You can get the exact html from the page using this:




httpresponse = (HttpWebResponse)httprequest.GetResponse();


catch(Exception e)


if(e is WebException)


WebException wexError = (WebException)e;

if(wexError.Status == WebExceptionStatus.ProtocolError)


WebResponse wrError = wexError.Response;

Stream stmError = wrError.GetResponseStream();

StreamReader srError= new StreamReader(stmError);

string strError = srError.ReadToEnd();







This really helped me!


Also, If anyone is interested in a freelance .NET development job, please have a look at http://www.webtropy.com/articles/joboffer.asp

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: