2

我的 MVC 项目根目录中的 web.config 文件中确实存在自定义错误。

<customErrors mode="On" defaultRedirect="~/Error">
  <error statusCode="403" redirect="~/Error/UnauthorizedAccess" />
  <error statusCode="404" redirect="~/Error/NotFound" />
</customErrors>

但是,当我在 IIS 7 中部署项目时,任何浏览 Web 应用程序的尝试都会在浏览器中产生此错误:

Description: An application error occurred on the server. The current custom error 
settings for this application prevent the details of the application error from being 
viewed remotely (for security reasons). It could, however, be viewed by browsers 
running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote 
machines, please create a <customErrors> tag within a "web.config" configuration file 
located in the root directory of the current web application. This <customErrors> 
tag should then have its "mode" attribute set to "Off".

    <!-- Web.Config Configuration File -->

    <configuration>
        <system.web>
            <customErrors mode="Off"/>
        </system.web>
    </configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by 
modifying the "defaultRedirect" attribute of the application's <customErrors> configuration 
tag to point to a custom error page URL.    

    <!-- Web.Config Configuration File -->

    <configuration>
        <system.web>
            <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
        </system.web>
    </configuration>

在我的应用程序中,我处理了错误并记录了它们,还给一些团队成员发了电子邮件。当我在 Visual Studio 或本地运行应用程序时,所有这些都有效。但是当我浏览这个新部署的应用程序时,没有创建日志,也没有发送任何电子邮件。

更新

有趣的是,它确实进入了我的应用程序的错误处理程序。我知道这是因为地址栏上写着:

http://10.1.17.43/MyApp/Error?aspxerrorpath=/MyApp

我的应用程序中处理所有异常Error的控制器 ( ) 在哪里。ErrorController

4

1 回答 1

2

首先,我会尝试设置<customErrors mode="Off" />,只是为了看看潜在的错误信息是什么。这可能是某种配置错误。

由于正在调用应用程序的错误页面,因此错误页面本身很可能发生错误。设置<customErrors mode="Off" />将让您看到该错误是什么。

于 2013-03-21T20:09:31.753 回答