MVC路由配置 mvc路由 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 都已经不匹配你的路由了,你让人家怎么用你的路由跳404?路由不匹配会引发异常,可以在Global中配置application_error来跳转你指定的404页面。 protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); if (HttpContext.Current.Server.GetLastError() is HttpRequestValidationException) { HttpContext.Current.Response.Redirect("~/NiMei/NiDaYe"); HttpContext.Current.Server.ClearError(); } }或者在application_start中注册错误全局Filte protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalFilters.Filters.Add(new HandleErrorAttribute()); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); }在你的system.web里:<customErrors mode="On" defaultRedirect="/NiMei/Error"/> http://blog.csdn.net/afeiflyinsky/article/details/7622622 楼主Application_Error是一种处理方式,还有救是重写处理,如:protected override void HandleUnknownAction(string actionName) { try { base.HandleUnknownAction(actionName); } catch { Response.Redirect("404.html"); } } Ajax扩展控件版本问题 如何用XML修改GridView中的数据 为什么点一次链接会有多次请求? 跟你们说啊 关于asp.net项目中无法调用命名空间对象的问题!! ora-12560错误,请高手指点,急等 100分求助,web.config里面的customErrors 开发经验问题 在<a href=""></a>里面使用用一个数据库变量存储的链接地址,请高手帮忙 ASP.NET无法启动调试,急求大侠们回答。在线等。。。。 linq to sql修改数据库 RewritePath 放到IIS报404错误 是高手你就来
路由不匹配会引发异常,可以在Global中配置application_error来跳转你指定的404页面。
protected void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError(); if (HttpContext.Current.Server.GetLastError() is HttpRequestValidationException)
{
HttpContext.Current.Response.Redirect("~/NiMei/NiDaYe");
HttpContext.Current.Server.ClearError();
}
}或者在application_start中注册错误全局Filte protected void Application_Start()
{
AreaRegistration.RegisterAllAreas(); GlobalFilters.Filters.Add(new HandleErrorAttribute());
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}在你的system.web里:
<customErrors mode="On" defaultRedirect="/NiMei/Error"/>
protected override void HandleUnknownAction(string actionName)
{
try { base.HandleUnknownAction(actionName); }
catch { Response.Redirect("404.html"); }
}