asp.net 在global中拦截404错误的实现方法_asp.net教程-查字典教程网
asp.net 在global中拦截404错误的实现方法
asp.net 在global中拦截404错误的实现方法
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:voidApplication_Error(objectsender,EventArgse){if(Context!=nu...

复制代码 代码如下:

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教程学习
    热门asp.net教程学习
    编程开发子分类