ASP.net MVC [的HandleError]未捕获异常 [英] ASP.net MVC [HandleError] not catching exceptions

查看:90
本文介绍了ASP.net MVC [的HandleError]未捕获异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在两个不同的应用,一个是其他的自定义样本MVC应用程序,你有一个新的VS2008 MVC项目获得,[调用HandleError]未捕获异常。

In two different application, one a custom the other the sample MVC application you get with a new VS2008 MVC project, [HandleError] is not catching exceptions.

在示例应用程序中我有:

In the sample application I have:

[HandleError]
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewData["Message"] = "Welcome to ASP.NET MVC!";
        throw new Exception();
        return View();
    }

    public ActionResult About()
    {
        return View();
    }
}

这只是一个例外,默认的控制器被抛出的测试。

which is just the default controller with an exception being thrown for testing.

但它不工作。而不是到默认error.aspx页面它示出了在浏览器中的调试信息。

But it doesn't work. Instead of going to the default error.aspx page it shows the debug information in the browser.

问题首次出现了在我工作的这一个自定义应用程序使我与示例应用程序进行测试。思考它必须是与我在自定义应用程序中所做的更改,我离开了示例应用程序中的指数法抛出的异常(呸)完全不变。

The problem first cropped up in a custom application I'm working on which led me to test it with the sample application. Thinking it had something to do with changes I made in the custom application, I left the sample application completely unchanged with the exception (yuck) of the throw in the index method.

我难倒。我缺少什么?

推荐答案

在Web.config中,变化的customErrors:

In Web.config, change customErrors:

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

如果模式是关闭或仅限远程,然后你会看到死亡的黄色屏幕,而不是自定义错误页。其理由是,开发商通常希望死亡的黄色屏幕上的更多详细信息。

If mode is either Off or RemoteOnly, then you will see the yellow screen of death instead of the custom error page. The reasoning is that developers usually want the more detailed information on the yellow screen of death.

这篇关于ASP.net MVC [的HandleError]未捕获异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆