tags:

views:

306

answers:

3

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
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
It should be downvoted.
Muhammad Akhtar
+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