Hello Atif.
I'm now struggling with similar problem. In my case, when I added <or>
node, I now get no e-mails with notifications at all. What could be
causing this situation? Below you can find an extract from my
web.config. As a result I'm getting no e-mails at all for some reason.
<errorFilter>
<test>
<or>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
<and>
<equal binding="Exception.Message" value="Padding is invalid and
cannot be removed." type="String" />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
</or>
</test>
</errorFilter>
I quickly gave your filter test a spin and it should be working fine. Below are the results of my interactive tests in IronPython 2.6.1 on .NET 4.0 using ELMAH 1.1:
IronPython 2.6.1 (2.6.10920.0) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>>
>>> clr.AddReference('Elmah')
>>> from Elmah.Assertions import AssertionFactory
>>> from Elmah import ErrorMailModule, ErrorLogModule
>>> from Elmah.ErrorFilterModule import AssertionHelperContext
>>>
>>> clr.AddReference('System.Web')
>>> from System.Web import HttpException
>>>
>>> clr.AddReference('System.Xml')
>>> from System.Xml import XmlDocument
>>>
>>> xml = """
... <or>
... <and>
... <equal binding="HttpStatusCode"
... value="404" type="Int32" />
... <regex binding="FilterSourceType.Name"
... pattern="mail" />
... </and>
... <and>
... <equal binding="Exception.Message"
... value="Padding is invalid and cannot be removed."
... type="String" />
... <regex binding="FilterSourceType.Name"
... pattern="mail" />
... </and>
... </or>
... """
>>>
>>> config = XmlDocument()
>>> config.LoadXml(xml)
>>>
>>> assertion = AssertionFactory.Create(config.DocumentElement)
>>>
>>> mailmod = ErrorMailModule()
>>> logmod = ErrorLogModule()
>>>
>>> error = HttpException(404, None)
>>> context = AssertionHelperContext(mailmod, error, None)
>>> print assertion.Test(context)
True
>>>
>>> error = HttpException(500, None)
>>> context = AssertionHelperContext(mailmod, error, None)
>>> print assertion.Test(context)
False
>>>
>>> error = HttpException('Padding is invalid and cannot be removed.')
>>> context = AssertionHelperContext(mailmod, error, None)
>>> print assertion.Test(context)
True
>>>
>>> context = AssertionHelperContext(logmod, error, None)
>>> print assertion.Test(context)
False
>>>
If the above appears distorted due to line-wrapping, I've also posted a version at:
http://gist.github.com/405314
Where you see True, the error should not get mailed, which is I think what you want.