Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
What I need to implement is that if either of the databases (oracle) are not available, server down etc, then redirect the user to another error page.
Posted

Use a try...catch block around the availablity test and use Response.Redirect[^] if it fails.

There is Oracle Ping info here: http://www.lorentzcenter.nl/awcourse/oracle/network.920/a96580/connect.htm[^]
 
Share this answer
 
Once you create a WebPage you automatically derive from System.Web.UI.Page. The Page object helps you trap page-level errors. In order to perform this you need to override it's OnError method.
protected override void OnError(EventArgs e)
{
  
  HttpContext ctx = HttpContext.Current;
  Exception exception = ctx.Server.GetLastError (); /*here you can even analyze what kind of error occurred*/
  string errorInfo =
     "<br>Offending URL: " + ctx.Request.Url.ToString () +
     "<br>Source: " + exception.Source +
     "<br>Message: " + exception.Message +
     "<br>Stack trace: " + exception.StackTrace;
  /*If you want to redirect use Response.Redirect*/
  ctx.Response.Write (errorInfo);
  ctx.Server.ClearError ();
  base.OnError (e);
}

Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900