Today I ran into a problem where my HttpModule was not working. No matter what I did I could not access my code under Visual Studio debugger. In other words my breakpoints did not work.
After a long time of wondering and some Googling I found out that the problem was related to how my HttpModule was being registered to the web application.
In my case I was working on a SharePoint 2010 project and was adding the module registration through a feature.
To put it simple if you are using IIS7 you need to register it under the “modules” element in the web.config file. If you are using lets say IIS6 then you need to register the module under the httpmodules element of the web.config file.
Example under IIS7:
return new SPWebConfigModification(“add[@name=’My.HttpModule’]”, “configuration/system.web/modules”)
Value = @”<add name=””My.HttpModule”” type=””myassembly namespace info etc”” />”,
Owner = properties.Feature.DefinitionId.ToString(),
Sequence = 0,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode