ASP.NET错误处理(500)

时间:2016-08-30 01:35:48

标签: c# asp.net asp.net-mvc asp.net-mvc-5

情景:

  • 代码抛出错误
  • Global.asax.cs中的
  • Application_Error称为

我想要的是什么:

  • 使用普通的MVC系统执行路径~/Error/InternalError(使用ErrorController.InternalError
  • 网址不会更改
  • Server.GetLastError()工作(来自错误控制器)

什么行不通:

  • 自定义错误(system.web)/ HTTP错误(system.webServer)
    • Server.GetLastError()返回null
  • Request.RewritePath()
    • 永远不会调用错误控制器
  • Server.Transfer()
    • 引发异常
  • Server.TransferRequest()
    • Server.GetLastError()返回null
  • IController.Execute()
    • 如上所述,我想使用普通的MVC管道来做到这一点。我特别不想自己实例化控制器。

这不可能吗?

0 个答案:

没有答案