手机
当前位置:查字典教程网 >编程开发 >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读取excel文件的三种方法示例

asp.net 生成曲线图实现代码

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

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

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

asp.net 文件下载实现代码

asp.net GridView 中增加记录的方法

asp.net SAF 中缓存服务的实现第1/5页

将Asp.Net网站发布到IIS的四种方法

asp.net中包含文件的代码及使用方法

精品推荐
分类导航