Asp.net Global.asax文件中的Server.Transfer()显示问题
我正在使用Global.asax页面进行错误处理。当出现错误时,我想转到错误页面以显示友好消息。但是它没有显示该页面。您是否尝试过这样做:Asp.net Global.asax文件中的Server.Transfer()显示问题,asp.net,Asp.net,我正在使用Global.asax页面进行错误处理。当出现错误时,我想转到错误页面以显示友好消息。但是它没有显示该页面。您是否尝试过这样做: public class Global : System.Web.HttpApplication { protected void Application_Error(object sender, EventArgs e) { Exception exception = Context.Server.GetLastError(
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");
}
}
确保你的文件存在。。。ShowErrorPage.htm
请尝试respone.redirect而不是server.transfer,如
Exception exception = Context.Server.GetLastError().GetBaseException();
Response.Redirect("~/ShowErrorPage.htm");