我不觉得这很容易设置。设置配置中缺少步骤,无法正常工作,或者我实际上并不了解它的目的。这里肯定有问题。问题显然是我。我只是没有让这个工作。这就是我所做的。
创建一个全新的 mvc 应用程序。将以下内容放在 About.aspx 页面上。
<% 抛出新异常(“废话”);%> 把内容放在这里。
点击页面得到黄屏异常。
将 elmah.dll 添加到 bin 目录。
在 Web.config 文件中添加配置节:
<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>
将以下内容添加到 httpHandlers 部分:
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
添加到模块部分:
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
添加到处理程序部分:
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" preCondition="integratedMode" type="Elmah.ErrorLogPageFactory, Elmah"/>
添加一个 elmah 部分:
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
这里令人好奇的是,该字符串的“.XmlFileErrorLog”部分显示为红色,显示为 ReSharper 错误,表明它“无法解析符号 '.ctor'”,当我查看 Reflector 中的 elmah.dll 时,显示该对象需要两个公共构造函数中的任何一个中的“字符串”或“IDicationary”。
我正在运行带有 VS 2008 的 Windows Vista x64。将 App_Data 的权限设置为所有人作为 Co_Owner。
http : //localhost:xxxx/elmah.axd页面确实出现并且没有显示错误。当我再次点击“关于”页面时,我仍然看到黄色屏幕,并且 elmah.axd 仍然没有显示 app_data 文件夹错误。
我用 customerrors 替换并创建了关联页面:
<customErrors mode="On" defaultRedirect="GenericErrorPage.htm" />
自定义页面显示,但 elmah.axd 仍显示“无错误”。app_data 还是空的!
作为启动此设置的来源,我使用了:code.google.com/p/elmah/wiki/MVC
那我在哪里搞砸了?
~-=迈克=-~