复制代码 代码如下:
<customErrors mode="On" defaultRedirect="404.aspx">
<error statusCode="403" redirect="404.aspx" />
<error statusCode="404" redirect="404.aspx" />
<error statusCode="400" redirect="404.aspx" />
</customErrors>
复制代码 代码如下:
protected void Application_Error(object sender, EventArgs e)
{
//在出现未处理的错误时运行的代码
this.FileNotFound_Error();
}
/// <summary>
/// 404错误处理
/// </summary>
private void FileNotFound_Error()
{
HttpException erroy = Server.GetLastError() as HttpException;
if (erroy != null && erroy.GetHttpCode() == 404)
{
Server.ClearError();
string path = "~/404.aspx";
Server.Transfer(path);
//Context.Handler = PageParser.GetCompiledPageInstance(path, Server.MapPath(path), Context);
}
}
新闻热点
疑难解答
图片精选