时间:2021-11-22 11:10:55 | 栏目:.NET代码 | 点击:次
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CustomErrorsDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
throw new Exception("故意抛出的异常。");
}
}
<customErrors mode="RemoteOnly">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
<customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="403.htm" />
<error statusCode="404" redirect="404.htm" />
</customErrors>