1. 首页
  2. 数据库
  3. 其它
  4. asp.net 在global中拦截404错误的实现方法

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

上传者: 2021-01-03 21:46:52上传 PDF文件 28.11KB 热度 6次
代码如下: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”,
下载地址
用户评论