.net 4 MVC 2 Elmah is logging background-image
I am using Elmah in my MVC 2 project and everything works fine - except that Elmah is logging my background-image as an not implemented controller (see http://imageshack.us/photo/my-images/834/unbenannt1ak.png/).
This image is set in my css via
body
{
background: #d9dbea url('scanlines.png');
}
开发者_运维百科Why is this happening?
Ok I finally got this one...
It seems to be a "common" bug, that Elmah logs the favicon.ico
if it is not located in your root directory. In order to overcome this problem you might create a filter as follows. I only had to add another filter rule so that Elmah does not log the scanlines.png
(or just another image) as I said before. The filter rule is
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<or>
<regex binding="Context.Request.ServerVariables['URL']"
pattern="/favicon\.ico(\z|\?)" />
<regex binding="Context.Request.ServerVariables['URL']"
pattern="/scanlines\.png(\z|\?)" />
<regex binding="Context.Request.ServerVariables['URL']"
pattern="/yourimage\.jpg(\z|\?)" />
</or>
</and>
</test>
</errorFilter>
With this you are able to block unwanted images logged by Elmah. Hope this might help someone ;-)
精彩评论