0

ELMAH generates an exception like below when a known process visits a non-existing URL on our website:

System.Web.HttpException: The controller for path '/manager/' was not found or does not implement IController.

Whereas going to that non-existent URL from a browser generates a typical IIS 404.

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /manager

I know the process accessing these addresses is harmless, and want to stop receiving these specific emails being generated from a range of IP addresses. This is what I have in web.config but ELMAH email still comes through.

The URL filter seems to be working fine.

      <elmah>
        <security allowRemoteAccess="false" />
        <errorMail from="elmah@mydomain.com" to="elmahlog@mydomain.com" async="true" smtpServer="mail.mydomain.com" smtpPort="25" useSsl="false" />
        <errorFilter>
          <test>
            <and>
              <equal binding="HttpStatusCode" value="500" type="Int32" />
              <or>
                <!--TrustWave scans our website with intentional bad addresses-->
                <regex binding="Context.Request.ServerVariables['REMOTE_ADDR']" pattern="64.37.231.\d{1,3}" type="String" />

                <!--Google looking for Digital Asset Links - well known statements the website wants to make-->
              <regex binding="Context.Request.ServerVariables['URL']" pattern="/.well-known/assetlinks.json" type="String" />

                <!--Apple devices searching for universal links - app-site association. we dont have an app.-->
                <regex binding="Context.Request.ServerVariables['URL']" pattern="/.well-known/apple-app-site-association" type="String" />            
              </or>
            </and>
          </test>
        </errorFilter>
      </elmah>
joym8
  • 4,014
  • 3
  • 50
  • 93

1 Answers1

0

Even though ELMAH email message looks like a 500 error occurred, the web.config really needed a 404 error code for the filter to work.

<equal binding="HttpStatusCode" value="404" type="Int32" />

instead of

<equal binding="HttpStatusCode" value="500" type="Int32" />

joym8
  • 4,014
  • 3
  • 50
  • 93