2013-05-07 54 views
1

如何使現有響應以errorMode爲條件?例如,如果errorMode =「DetailedLocalOnly」,那麼我希望外部消息被我的自定義定義(即友好錯誤頁面)「替換」,但我希望本地消息是「passedThrough」。所以,對於500錯誤,我在本地看到YSOD,而不是IIS 500錯誤頁面。在外部,我會看到我的友好錯誤頁面。httpErrors有關errorMode的條件?

這可能嗎?

我目前的配置:

<httpErrors existingResponse="Replace" errorMode="DetailedLocalOnly"> 
    <remove statusCode="500" /> 
    <error statusCode="500" path="/myCustomErrorPage" responseMode="ExecuteURL" /> 
</httpErrors> 

回答

1

不幸的是這是不可能做到這一點。您可以使用事件日誌查看相關詳細說明,你也可以用錯誤的詳細信息通過電子郵件發送自己:

<healthMonitoring enabled="true" heartbeatInterval="0"> 
    <eventMappings> 
     <clear /> 
     <add name="All Errors" type="System.Web.Management.WebBaseErrorEvent, System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" startEventCode="0" endEventCode="2147483647" /> 
    </eventMappings> 
    <providers> 
     <clear /> 
     <add name="EmailProvider" type="System.Web.Management.SimpleMailWebEventProvider" to="[email protected]" from="[email protected]" buffer="true" bufferMode="Logging" /> 
     <add name="EventLogProvider" type="System.Web.Management.EventLogWebEventProvider" /> 
    </providers> 
    <rules> 
     <clear /> 
     <add name="EmailRule" eventName="All Errors" provider="EmailProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" /> 
     <add name="EventLogRule" eventName="All Errors" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" /> 
    </rules> 
</healthMonitoring> 

調整minInterval如果你只希望接收例如通知每小時或每一天。當然,確保你已經爲你的網絡服務器配置了你的電子郵件。例如。

<system.net> 
    <mailSettings> 
     <smtp deliveryMethod="SpecifiedPickupDirectory"> 
      <specifiedPickupDirectory pickupDirectoryLocation="C:\MailPickUpFolders\ExampleDomain" /> 
      <network host="localhost" port="25" /> 
     </smtp> 
     <!--<smtp deliveryMethod="Network"> 
      <network host="yoursever" port="25" /> 
     </smtp>--> 
    </mailSettings> 
</system.net>