J
Jon Maz
Hi All,
I am using a WebRequest & WebResponse to GET the contents of an aspx page as
a string (code below).
It's working fine, except that when the aspx page has an error on it, I want
to know precisely what the error was (ie I want to get the error message
that would be displayed if you were viewing the aspx page in a brower).
Instead I always get this error:
The remote server returned an error: (500) Internal Server Error
pointing to the line:
WebResponse myResponse = myRequest.GetResponse();
Can anyone tell me how I can GET the original error text returned to me?
Thanks,
JON
=====
CODE
=====
// Initialize the WebRequest.
WebRequest myRequest =
WebRequest.Create("http://localhost/PageWithError.aspx");
// Return the response.
WebResponse myResponse = myRequest.GetResponse();
// Convert the GET to a string and display it
StreamReader sr = new
StreamReader(myResponse.GetResponseStream(),System.Text.Encoding.Default);
string sBuffer;
sBuffer = sr.ReadToEnd();
sr.Close();
txtDisplayHtml.Text = sBuffer;
I am using a WebRequest & WebResponse to GET the contents of an aspx page as
a string (code below).
It's working fine, except that when the aspx page has an error on it, I want
to know precisely what the error was (ie I want to get the error message
that would be displayed if you were viewing the aspx page in a brower).
Instead I always get this error:
The remote server returned an error: (500) Internal Server Error
pointing to the line:
WebResponse myResponse = myRequest.GetResponse();
Can anyone tell me how I can GET the original error text returned to me?
Thanks,
JON
=====
CODE
=====
// Initialize the WebRequest.
WebRequest myRequest =
WebRequest.Create("http://localhost/PageWithError.aspx");
// Return the response.
WebResponse myResponse = myRequest.GetResponse();
// Convert the GET to a string and display it
StreamReader sr = new
StreamReader(myResponse.GetResponseStream(),System.Text.Encoding.Default);
string sBuffer;
sBuffer = sr.ReadToEnd();
sr.Close();
txtDisplayHtml.Text = sBuffer;