CustomErrors Trapping in a Page

  • Thread starter Thread starter SMG
  • Start date Start date
S

SMG

Hi All,

I am using following code in web.confiig for trapping all the error through
out my site..

<customErrors mode="On" defaultRedirect="WebForm1.aspx">
<error statusCode="404" redirect="ServerError.aspx"></error>
<error statusCode="500" redirect="WebForm3.aspx"></error>
</customErrors>

It works very fine... but On the final page e.g WebForm3.aspx I want catch
the error and want to show it on the screen.
so i wrote following code in webform3.aspx

string strErrorMsg = "Application Error\n\n";

// Get the path of the page
strErrorMsg += "Error in Path :" + Request.Path;

// Get the QueryString along with the Virtual Path
strErrorMsg += "\n\n Error Raw Url :" + Request.RawUrl;

// Create an Exception object from the Last error
//that occurred on the server
Exception myError =Server.GetLastError();

// Get the error message
strErrorMsg += "\n\nError Message :" + myError.Message;

Regards,
Shailesh Gajare
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top