registering httpModules in web.config

Viewed 52169

I am trying to register a custom HttpHandler in the web.config file. MSDN's example shows an entry that is commented out...um which doesn't work so well. When I uncomment I receive a Could not load file or assembly 'HttpModule.cs' or one of its dependencies. The system cannot find the file specified. error. The file name is HttpModule.cs and the class name is MyHttpModule. There is no explicit namespace yet.

<httpModules>
     <add name="MyHttpModule" type="MyHttpModule, HttpModule" />
<httpModules>

I am sure I am overlooking the obvious. Do I need to specify the file path somewhere? Thanks in advance.

6 Answers

I think HttpModules property in system.web is for ASP 3.5 or before. For ASP 4 or above use modules in system.webserver:

<system.webServer>
    <modules>
        <add name="TestModule"  type="WebApplication1.TestModule, WebApplication1"/>
    </modules>
    <validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
Related