更新时间:2023-02-15 22:46:12
将其放在您的Global
文件中:
protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
// Do something with the error.
System.Diagnostics.Debug.WriteLine(exception);
// Redirect somewhere or return an error code in case of web api
Response.Redirect("/Home/Error");
}
任何时候,都会发生错误,ASP MVC会调用该方法.
Anytime, an error occurs, ASP MVC will call that method.