我正在使用Global.asax页面进行错误处理。虽然有一个错误我想转移到错误页面以显示友好的消息。但它没有显示该页面。
答案 0 :(得分:1)
你试过这样的事吗:
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");
}
}
答案 1 :(得分:1)
确保你的文件存在... ShowErrorPage.htm
尝试respone.redirect而不是像....一样的server.transfer。
Exception exception = Context.Server.GetLastError().GetBaseException();
Response.Redirect("~/ShowErrorPage.htm");