实现代码如下:

void Application_Error(object sender, EventArgs e)
{
if(Context != null)
{
HttpContext ctx = HttpContext.Current;
Exception ex = ctx.Server.GetLastError();
HttpException ev = ex as HttpException;
if(ev!= null)
{
if(ev.GetHttpCode() == 404)
{
ctx.ClearError();
Response.Redirect("~/nofound.aspx", false);
Response.End();
}
else
{
Server.Transfer("~/Error.aspx", false);
}
}
}
}

以上就是【asp.net 在global中拦截404错误的实现方法】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)
发表我的评论

最新评论

  1. 暂无评论