您的位置:首页 > 编程语言 > ASP

asp.net 在global中拦截404错误的实现方法

2010-03-05 00:00 696 查看
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); 
} 
} 
} 
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: