My HttpModule never hits the OnError event when I throw an exception

556 views Asked by At

I created a simple web forms application and created a class library project inside this solution as a project reference. This class library project is my HttpModule. The idea of this is so I can step into my HttpModule code. Here's what my solution looks like:

enter image description here

In Default.aspx.cs, I threw an exception to see if OnError in my HttpModule would catch it (which it doesn't catch it - it never hits my breakpoint inside OnError):

enter image description here

Finally, here's my web.config:

enter image description here

QUESTION: Can anyone tell me what I might be doing wrong? I'm not entirely confident with my web.config entry. Does the web.config entry look okay? Could adding this HttpModule via a project reference be causing an issue?

1

There are 1 answers

0
Luaan On BEST ANSWER

Are you running your application in Integrated mode? If so, you have to add your http module to the system.webServer/modules configuration section, rather than system.web/httpModules

<configuration>
  <system.webServer>
    <modules>
       <add name="ErrorModule" type="ErrorModule, ErrorModule"/>
    </modules>
  </system.webServer>
</configuration>