Global.asax

protected void Application_Error(object sender, EventArgs e)

{
      Application["error"] = Server.GetLastError().Message;
      this.Response.Redirect("error.aspx");
}

原文地址:https://www.cnblogs.com/greencolor/p/1703696.html