2012-05-17 51 views
0

我有這個很奇怪的問題:網站給出了一個白頁而不是404錯誤

當我去到我的網站上不存在的URL時,它只是顯示一個白頁。 Application_Error事件永遠不會運行,並且用戶不會轉移到我們使用的404頁面。

我需要趕上Application_Error事件,做一些日誌記錄和一些重定向。

我沒有訪問IIS的權限,因爲我在共享的webhotel上運行我的網站。但與我所有的其他網站這工作正常。

這裏是我的web.config:

<?xml version="1.0"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </assemblies> 
    </compilation> 
    <pages> 
     <controls> 
     <add src="~/UC/Filters.ascx" tagName="Filters" tagPrefix="uc2"/> 
     </controls> 
    </pages> 
    <httpRuntime maxRequestLength="1048576" requestValidationMode="2.0"/> 
    <customErrors mode="Off" defaultRedirect="ErrorPage.aspx"> 
     <error statusCode="404" redirect="404-Error.aspx"/> 
    </customErrors> 
    <sessionState timeout="5000"/> 
    </system.web> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <handlers> 
     <add name="AjaxToolkit" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
    </handlers> 
    <rewrite> 
     <rules> 
     <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true"> 
      <match url="*"/> 
      <conditions> 
      <add input="{HTTP_HOST}" pattern="domain.com"/> 
      </conditions> 
      <action type="Redirect" url="http://www.domain.com/{R:0}"/> 
     </rule> 
     <!--To always remove trailing slash from the URL--> 
     <rule name="Remove trailing slash" stopProcessing="true"> 
      <match url="(.*)/$"/> 
      <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> 
      </conditions> 
      <action type="Redirect" redirectType="Permanent" url="{R:1}"/> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

任何想法?謝謝:-D

回答

0

設置自定義錯誤:

<customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.aspx"> 
    <error statusCode="404" redirect="404-Error.aspx"/> 
</customErrors> 
+0

這並沒有區別:/ –

+0

這是對MVC?看看http://stackoverflow.com/questions/6508415/application-error-not-firing-when-customerrors-on/9572858#9572858 – Max

+0

不,網頁形式:) –

相關問題