0

我正在尝试关注有关自定义错误句柄的文章。我设置了我的控制器、视图和全局文件。当我导航到 Error/HttpError 时,我看到了我的页面。但是,当我尝试在我的一个控制器中抛出一个新异常时,我的任何错误代码都不会触发或将我重定向到任何地方,应用程序 on_error 也不会触发。

它只是给了我这个:

Error handler test
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ApplicationException: Error handler test

Source Error:

Line 275:        public ActionResult Website(RerModel model) {
Line 276:
Line 277:            throw new ApplicationException("Error handler test");  
Line 278:
Line 279:            var step = "Website";

我肯定错过了什么?

4

1 回答 1

0

我认为问题在于您已将视图放在名为“错误”的文件夹中。我认为您需要将其移动到共享(或特定于控制器的文件夹)中。默认情况下,MVC 不会在名为“Error”的文件夹中查找错误视图。

于 2011-02-28T18:56:08.530 回答