asp.net - Elmah 仅在 asp.net mvc Release模式下

标签 asp.net asp.net-mvc elmah

我已通过 NuGet 管理器控制台安装了 Elmah(具有默认设置的标准包)。

为了进行测试和更好地理解,我尝试重新配置它,使其仅在“ Debug模式”下运行(在成功测试后,我希望有两种不同的配置用于调试和发布,例如在发布中发送电子邮件,在调试中不发送电子邮件)等)。

因此,我已将大部分(工作)配置从 Web.config 移至 Web.Debug.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <configSections>
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>
  </configSections>
  <system.web>
    <httpModules>
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
    </httpModules>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
    </modules>
  </system.webServer>
  <elmah>
    <security allowRemoteAccess="false" />
    <errorMail from="XXXX" to="XXXX"
                async="true"  smtpPort="0" />
  </elmah>
  <location path="elmah.axd" inheritInChildApplications="false">
    <system.web>
      <httpHandlers>
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
      </httpHandlers>
    </system.web>
    <system.webServer>
      <handlers>
        <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  </location>
</configuration>

现在,当我尝试打开 elmah.axd 页面时,我收到“找不到资源”。错误。 我错过了什么吗?

最佳答案

在本地,您应该使用 web.config 文件。

调试或 Release模式实际上与使用哪个配置文件没有任何关系。只有在部署时才会发生转换:

web.config

这是开发人员应在本地使用的配置文件。理想情况下,您应该将其标准化。例如,您可以使用 localhost 作为数据库字符串,等等。您应该努力使其无需更改即可在开发计算机上运行。

web.debug.config

这是将应用程序发布到开发临时环境时应用的转换。这将对目标环境所需的 web.config 进行更改。

web.release.config

这是将应用程序发布到“生产”环境时应用的转换。显然,根据您的应用程序/团队,您必须小心密码。

引用链接:http://blogs.msdn.com/b/webdev/archive/2010/10/26/asp-net-web-projects-web-debug-config-amp-web-release-config.aspx

关于asp.net - Elmah 仅在 asp.net mvc Release模式下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16559216/

相关文章:

jquery - Asp.net ajax 与 mvc2

javascript - 通过输入中的输入按钮新建行(ASP.NET MVC)

asp.net-mvc - MVC OutputCache for Child Actions : where is it stored?

asp.net-mvc-5 - 使用 ASP.NET MVC 5 和 Elmah 的自定义错误页面

c# - ASP.NET MVC5 Elmah 错误日志/电子邮件找不到路径的 Controller

asp.net - 将 Elmah 与卡西尼号一起使用

c# - .net 4.5 是对 4.0 的重大升级还是只是包含更新 .dll 的问题?

c# - 非常简单的 ASP.NET 3.5 应用程序的问题,使用 C#

javascript - 将 jQuery post 发送到 MVC Controller 时出现 404 错误

c# - 通过将控件的 ID 属性设置为 "itemPlaceholder"来指定项目占位符