Do you know that 'httpHandlers' or 'httpModules' sections in web.config must contain a 'remove' or 'clear' element?
Rules to Better Website Development - ASP.NET|d1c7c6c6-dfe7-414b-a26a-771be26ab596
v4.0
Posted at
20/05/2017 5:44 AM by
Tiago Araujo
Rule Intro
If web.config contains a <httpHandlers> or <httpModules> section, that section must contain a <remove... /> or a <clear /> element.
This basically forces developers to explicitly enable inheritance in nested virtual directories. In 99% of cases this developers won't use inheritance on these two sections, however it causes issues when somebody wants to add a module or handler to the parent virtual directory.
Page Content
<configuration>
<system.web>
<httpHandlers>
<add verb="*"
path="*.New"
type="MyHandler.New,MyHandler"/>
<add verb="GET,HEAD"
path="*.MyNewFileExtension"
type="MyHandler.MNFEHandler,MyHandler.dll"/>
</httpHandlers>
<system.web>
</configuration>
- Figure: Bad example
<configuration>
<system.web>
<httpHandlers>
<clear/>
<add verb="*"
path="*.New"
type="MyHandler.New,MyHandler"/>
<add verb="GET,HEAD"
path="*.MyNewFileExtension"
type="MyHandler.MNFEHandler,MyHandler.dll"/>
</httpHandlers>
<system.web>
<configuration>
- Figure: Good example
{14359E59-B047-4E0B-AEF5-F79CCD3EB373}
Do you feel this rule needs an update?