这篇文章主要介绍了asp.net错误页面处理示例,需要的朋友可以参考下
1.新建Golbal.asax 代码如下:void Application_Error(object sender, EventArgs e) { Exception objErr = Server.GetLastError().GetBaseException(); string error = "发生异常页: " + Request.Url.ToString() + "<br>"; error += "异常信息: " + objErr.Message + "<br>"; Server.ClearError(80s电影网[www.aikan.tv/special/80sdianyingwang/]); Application["error"] = error; Response.Redirect("~/ErrorPage/ErrorPage.aspx");} 2.前台部分: 代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ErrorPage.aspx.cs" Inherits="ErrorPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>ErrorPage</title><script language="javascript" type="text/javascript">function CheckError_onclick() {var chk = document.getElementById("CheckError");var divError = document.getElementById("errorMsg");if(chk.checked){ divError.style.display = "inline";}else{ divError.style.display = "none";}} </script></head><body><form id="form1" runat="server"><div style="text-align: center"><asp:Label ID="Label1" runat="server" Text="