手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net 在global中拦截404错误的实现方法
asp.net 在global中拦截404错误的实现方法
摘要:复制代码代码如下: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 在global中拦截404错误的实现方法】相关文章:

asp.net水晶报表参数字段在代码中赋值的方法

asp.net在后端动态添加样式表调用的方法

asp.net注册Javascript的方法

asp.net 参数不同共用一个页面的实现方法

asp.net程序编译调试时偶尔出现访问被拒绝的错误的解决方法

asp.net跳转页面的三种方法比较

asp.net下URL处理两个小工具方法

asp.net为网页动态添加description描述信息的方法

asp.net String.IsNullOrEmpty 方法

Ajax.net 显示错误信息的设置

精品推荐
分类导航