2012-05-17 52 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

不,网页形式:) –

相关问题