【问题标题】:Disable customErrors only for a given Area in MVC仅对 MVC 中的给定区域禁用 customErrors
【发布时间】:2015-04-24 13:00:35
【问题描述】:

我在我的MVC5 Web 应用程序中启用了customErrors,如下所示。

<customErrors defaultRedirect="/Error/InternalServerError" mode="On">
  <error redirect="/Error/NotFound" statusCode="404" />
  <error redirect="/Error/InternalServerError" statusCode="500" />
</customErrors>

我定义了名为“Admin”的区域,我需要为该特定区域关闭 customErrors。

我尝试在 Areas 文件夹中添加带有以下代码的 web.config 文件。

<?xml version="1.0"?>
<configuration>
  <system.web>
    <customErrors mode="Off" />
  </system.web>
</configuration> 

但我的自定义错误仍在显示,如何仅对 MVC5 中的给定区域禁用 customErrors?

【问题讨论】:

    标签: asp.net-mvc-5 custom-errors


    【解决方案1】:

    将您的 customErrors 包装在 root web.config 中的位置标记中:

      <location path="areaName">
          <system.web>
            <customErrors mode="Off" />
          </system.web>
      </location>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-29
      • 1970-01-01
      • 2010-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-03
      相关资源
      最近更新 更多