mvc中的程序错误之404(一),无法找到资源

运行程序的时候,如果,没有在controller的基础上运行的话会出错,
所以,为了解决这个错误,下面这个方法就是为了避免出现这样的错误,在文件global.asax中添加以下方法:

protected void Application_Error(object sender, EventArgs e)
{
  Exception LastError = Server.GetLastError();
  Response.Redirect("/error.htm");
}

自己添加error.html页面,随便写点东西即可

原文地址:https://www.cnblogs.com/angelgril/p/3069163.html