Sunday, December 14, 2008

Redirect to Error Page Using JavaScript

My readers enquired that how to rehuffle the yellow page on web.
The Yellow page appears when Web-Site got any runtime error.

I always suggested to supercede the Yellow-Page. Try the following code :


namespace AStepAhead.redirectErrorPage
{
public class redirectErrorPage
{
public redirectErrorPage()
{
String strDomainName = “MsDotnetHeaven.com”;
try
{
//Write you coding here
}
catch (Exception ex)
{
SystemFramework.ApplicationLog.WriteError(”Error : ” + ex.ToString());
//Redircet you main page to error page
Response.Write(”\n”);
Response.End();
}
}
}

}


Now, in error page, read ErrorString and show to the users.

Step(s): Followings are the steps to perform above:

1. Create an Error Page and named it as errorpage.aspx.
2. Read Error string at Page_load
3. Write above code in your Web Page.

After above, whenever any runtime exception occured, your user will see a maintained / designed error page.

No comments:

Post a Comment