gpt4 book ai didi

asp.net-mvc - MVC中的自定义错误处理问题

转载 作者:行者123 更新时间:2023-12-03 09:00:47 26 4
gpt4 key购买 nike

我正在尝试阅读有关自定义错误句柄的文章。我设置了 Controller , View 和全局文件。当我导航到Error/HttpError时,我看到了我的页面。但是,当我尝试在我的一个 Controller 中引发新的异常时,我的错误代码都不会触发或重定向我到任何地方,应用程序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";

我肯定错过了什么?

最佳答案

我认为问题在于您已将 View 放置在名为“错误”的文件夹中。我认为您需要将其移至“共享”(或 Controller 特定的文件夹)中。默认情况下,MVC不会在名为“错误”的文件夹中查找错误 View 。

关于asp.net-mvc - MVC中的自定义错误处理问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4926108/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com