Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net MVC中handlerror的实现_.net_Asp.net Mvc_Asp.net Mvc 4_Asp.net Mvc 3 - Fatal编程技术网

.net MVC中handlerror的实现

.net MVC中handlerror的实现,.net,asp.net-mvc,asp.net-mvc-4,asp.net-mvc-3,.net,Asp.net Mvc,Asp.net Mvc 4,Asp.net Mvc 3,我的MVC应用程序中有以下代码 [HandleError(View = "Error", ExceptionType = typeof(FormatException))] public ActionResult Indexerror() { throw new FormatException(); } 以及共享文件夹中名为>error的视图。 当我运行这个应用程序时,我无法看到创建的视图,相反,应用程序中会弹出一个服务器错误并显示一条消息

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

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

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

    } 
以及共享文件夹中名为>error的视图。 当我运行这个应用程序时,我无法看到创建的视图,相反,应用程序中会弹出一个服务器错误并显示一条消息

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


确保web.config中的CustomErrorMode处于打开状态。这应该是工作,我做了测试

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

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