2011-01-23 98 views
4

因此,我不知道是否有其他人遇到此問題,但如果我運行的是通過IIS 7.5 Express安裝ELMAH的asp.net網站,ELMAH拒絕登錄或甚至從數據庫中讀取。如果我通過卡西尼運行網站,一切都很好。 Elmah的工作就像一個魅力...Elmah不會通過iis 7.5 express記錄或讀取錯誤

是否有其他人遇到此問題?

+0

什麼數據庫?你如何設置/ web.config的樣子?請提供更多細節。 – 2011-01-23 21:06:49

+0

我正在使用MSSQL 2008 R2,但是,我只是設法將它整理出來。我剛剛從IIS Express Beta版升級到正式發行版。 – Marlon 2011-01-24 00:08:30

回答

5

根據你到目前爲止描述的內容,唯一可以解釋的解釋是ELMAH的模塊和處理程序可能僅在<system.web>下注冊,這就是爲什麼它們被ASP.NET開發服務器(卡西尼)。另一方面,IIS Express預計這些模塊和處理程序將在<system.webServer>下注冊。以下是摘自sample web.config supplied with ELMAH 1.1

<!-- 
    The <system.webServer> section is required for running ELMAH under Internet 
    Information Services 7.0. It is not necessary for previous version of IIS. 

    In general, it would be best to include it for all .NET Framework 2.0 and above 
    configurations in order to have a more portable solution between various 
    versions of IIS. 

    IIS 5.x, IIS 6 require the modules and handlers to be declared in <system.web> 
    whereas IIS 7 needs them declared here and complains if they are in fact 
    declared in <system.web>. Fortunately, the 
    <validation validateIntegratedModeConfiguration="false" /> entry tells IIS 7 
    not to worry about the modules and handlers declared in <system.web>. 

    If you only ever want to use IIS 7, then do the following: 

    1. Remove handlers and modules from <system.web> 
    2. Remove the <validation validateIntegratedModeConfiguration="false" /> element 
--> 

<system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules> 
     <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /> 
     <add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" preCondition="managedHandler" /> 
    </modules> 
    <handlers> 
     <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /> 
    </handlers> 
</system.webServer>