2014-01-06 41 views
0

我想將所有錯誤捕獲到default.aspx文件中,而不管服務器上發生了什麼。system.webserver中的httperrors無法在azure上工作

在web.config中,我說:

<system.webServer> 
    <httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" defaultPath="~/Default.aspx" existingResponse="Replace" > 
     <remove statusCode="404"/> 
     <remove statusCode="500"/> 
     <error statusCode="404" path="~/Default.aspx" responseMode="ExecuteURL"/> 
     <error statusCode="500" path="~/Default.aspx" responseMode="ExecuteURL"/> 
    </httpErrors> 
</system.webServer> 

它不工作。在一個問題中,我讀了關於允許重寫HttpErrors部分,但添加configSection中的某些內容不起作用,因爲type元素缺失。不知道那裏需要什麼。

<configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=ZZZZZZZZZ" requirePermission="false" /> 
    <section name="httpErrors" allowOverride="true"/> 
</configSections> 

回答

0

如果您想以處理ASP.NEt網站404條錯誤信息,那麼所有你需要的是有Web.Config中下一節 -

<customErrors mode="On" defaultRedirect="DefaultRedirectErrorPage"> 
     <error statusCode="404" redirect="Home/About"/> 
    </customErrors> 

對於不同的方式詳細瞭解錯誤在ASP.Net處理 - Ref this MSDN Resource

如果你想做的事,在httpErrors水平,那麼試試這個 -

<httpErrors errorMode="Custom" existingResponse="Replace"> 
    <!--Remove inherited 500 error page setting --> 
    <remove statusCode='404' subStatusCode='-1'/> 
    <!--Override the inherited 500 error page setting with the 'My500.html' as its path--> 
    <error statusCode='404' subStatusCode='-1' prefixLanguageFilePath='' path='/home/index' responseMode='ExecuteURL'/> 
</httpErrors> 
相關問題