【问题标题】:When I browse http://localhost:8004/elmah.axd, it generates 404 error当我浏览 http://localhost:8004/elmah.axd 时,它会生成 404 错误
【发布时间】:2012-06-16 10:02:54
【问题描述】:

当我浏览 http://localhost:8004/elmah.axd 时,它会显示应用程序中发生的错误,但也会产生 404 错误。我将如何停止这个 404 错误?

404错误的详细信息是:

System.Web.HttpException (0x80004005):文件不存在。 在 System.Web.StaticFileHandler.GetFileInfo(字符串 virtualPathWithPathInfo,字符串物理路径,HttpResponse 响应) 在 System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext 上下文,字符串 overrideVirtualPath) 在 System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext 上下文,AsyncCallback 回调,对象状态) 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,Boolean& completedSynchronously)

我的网络配置文件是这样的:

组> configSections > httpHandlers > http模块> 认证> ………… ………… 模块> 处理程序 > 埃尔玛 > 配置>

【问题讨论】:

    标签: asp.net elmah


    【解决方案1】:

    或者,您可以将以下内容添加到 web.config 文件中的 ELMAH 配置部分,以忽略 favicon.ico 请求。

    <elmah>
    
     ...
    
    <errorFilter>
      <!--    Do not capture 404 errors for favicon.ico file requests -->
      <test>
        <and>
          <equal binding="HttpStatusCode" value="404" type="Int32" />
          <regex binding="Context.Request.ServerVariables['URL']" pattern="/favicon.ico(\z|\?)" />
        </and>
      </test>
    </errorFilter>
    
    ...
    
    </elmah>
    

    【讨论】:

    • 我认为您需要从 ServerVariables['URL] 中删除 '
    【解决方案2】:

    我将如何停止这个 404 错误?

    /favicon.ico 添加到您的网络应用程序。当现代浏览器(例如 Google Chrome)请求 url 时,它们会向/favicon.ico 发送一个额外的 HTTP 请求,以显示与此页面关联的favicon。如果您的站点根目录中没有此类文件,Web 服务器将返回 404,这就是您在 Elmah 错误日志中观察到的内容。

    例如,尝试使用 Internet Explorer 浏览您的 elmah.axd,您将不会看到此类 404 错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      相关资源
      最近更新 更多