can we handle this issue under Application_Error() in global.asax,
as I displayed HttpUnhandledException type exception on error.aspx page but cant redirect for non HttpUnhandledException exception, so tried to show non HttpUnhandledException exception with Responce.Write() but it seems bad.
here is my code;
protected void Application_Error(object sender, EventArgs e)
{
//// Code that runs when an unhandled error occurs
HttpContext ctx = HttpContext.Current;
Exception exc = ctx.Server.GetLastError();
// Log the exception and notify system operators
Utilities.writeLog(this, exc);
if (exc is HttpUnhandledException)
{
// Pass the error on to the error page.
// Server.Transfer("ErrorPage.aspx?handler=Application_Error%20-%20Global.asax", true);
Response.Redirect("~/SITE/Home/ErrorPage.aspx");
}
else
{
Response.Clear();
if (null != exc)
Response.Write("<h1>" + exc.Message + "</h1>");
else
Response.Write("<h1>" + HttpContext.Current.AllErrors[0].Message.ToString() + "</h1>");
//Response.Write("<pre>" + exc.ToString() + "</pre>");
}
//Get the exception object.
Server.ClearError();
}
can we handle this issue under Application_Error() in global.asax,
as I tried to show non HttpUnhandledException exception on Responce.Redirect but it seems bad.s I tried to show non HttpUnhandledException exception on Responce.Redirect but it seems bad.
here is my code;ere is my code;
protected void Application_Error(object sender, EventArgs e)
{
//// Code that runs when an unhandled error occurs
HttpContext ctx = HttpContext.Current;
Exception exc = ctx.Server.GetLastError();
// Log the exception and notify system operators
Utilities.writeLog(this, exc);
if (exc is HttpUnhandledException)
{
// Pass the error on to the error page.
// Server.Transfer("ErrorPage.aspx?handler=Application_Error%20-%20Global.asax", true);
Response.Redirect("~/SITE/Home/ErrorPage.aspx");
}
else
{
Response.Clear();
if (null != exc)
Response.Write("
" + exc.Message + "
");
else
Response.Write("
" + HttpContext.Current.AllErrors[0].Message.ToString() + "
");
//Response.Write("
" + exc.ToString() + "
");
}
//Get the exception object.
Server.ClearError();
}protected void Application_Error(object sender, EventArgs e)
{
//// Code that runs when an unhandled error occurs
HttpContext ctx = HttpContext.Current;
Exception exc = ctx.Server.GetLastError();
// Log the exception and notify system operators
Utilities.writeLog(this, exc);
if (exc is HttpUnhandledException)
{
// Pass the error on to the error page.
// Server.Transfer("ErrorPage.aspx?handler=Application_Error%20-%20Global.asax", true);
Response.Redirect("~/SITE/Home/ErrorPage.aspx");
}
else
{
Response.Clear();
if (null != exc)
Response.Write("
" + exc.Message + "
");
else
Response.Write("
" + HttpContext.Current.AllErrors[0].Message.ToString() + "
");
//Response.Write("
" + exc.ToString() + "
");
}
//Get the exception object.
Server.ClearError();
}