【问题标题】:handlerror implementation in MVCMVC 中的 handlererror 实现
【发布时间】:2017-11-03 07:57:22
【问题描述】:

我的 MVC 应用程序中有以下代码。

 [HandleError(View = "Error", ExceptionType = typeof(FormatException))]

    public ActionResult Indexerror()
    {
        throw new FormatException();  

    } 

和共享文件夹中的一个名为 > 的视图错误。 当我运行此应用程序时,我无法看到创建的视图,而是在应用程序中弹出服务器错误并显示一条消息

对象引用未设置为对象的实例。

【问题讨论】:

  • 请在建议关闭之前发表评论。谢谢。

标签: .net asp.net-mvc asp.net-mvc-4 asp.net-mvc-3


【解决方案1】:

确保 CustomErrorMode 在 web.config 中为 On。应该可以的,我测试过了。

<system.web>
    <customErrors mode="On">
    </customErrors>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-28
    • 2011-06-25
    • 1970-01-01
    • 1970-01-01
    • 2016-07-18
    • 1970-01-01
    相关资源
    最近更新 更多