I am using Global.asax page for error handling. While there is an error I want to transfer to a Error page to show a friendly message. But it is not showing that page.
+1
A:
Have you tried like this:
public class Global : System.Web.HttpApplication
{
protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Context.Server.GetLastError().GetBaseException();
// TODO: Do something with the exception
Context.Response.StatusCode = 500;
Context.Server.Transfer("~/500.htm");
}
}
Darin Dimitrov
2009-07-08 07:20:45
A:
Here is my code:
void Application_Error(object sender, EventArgs e)
{
Exception exception = Context.Server.GetLastError().GetBaseException();
// I want to store it in some File
Context.Server.Transfer("~/ShowErrorPage.htm");
}
but it is showing
Error executing child request for /ShowErrorPage.htm.
Why voted to posted code?
Muhammad Akhtar
2009-10-14 18:56:17
It should be downvoted.
Muhammad Akhtar
2009-10-14 18:57:09
+1
A:
make sure ur file exist... ShowErrorPage.htm
try respone.redirect instead of server.transfer like....
Exception exception = Context.Server.GetLastError().GetBaseException();
Response.Redirect("~/ShowErrorPage.htm");
Muhammad Akhtar
2009-07-08 09:11:08