Asp.net MVC 如果出现错误路由 重定向到首页
Global.asax 添加下面内容
protected void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpException && ((HttpException)ex).GetHttpCode() == 404)
{
Response.Redirect("/home/index");
}
else
{
// your global error handling here!
}
}

浙公网安备 33010602011771号