views:

22

answers:

1

Question:

Normally, when you create a HTTP module, you create it as separate dll project and register that dll in the web.config.

Now, is it possible to write a HTTP module directly in an ASP.NET project, so I don't have to create a separate dll project?

Note: Don't say as an added project in the same solution, I mean in the same project.

Or would just adding a reference to this dll suffice ?

+2  A: 

I think that you can, you place your code/class inside the app_code directory, and that's all.

You then register it by his namespace and the class name on the web.config.

Aristos
I've tested, and you can replace 'I think' with 'I know'. Now the question: How can I make the web.config entry redundant? I mean surely there probably is a way to add a handler via code ?
Quandary
@Quandary You have right, about the "I think", and "I know", is because I have done this in the past, but I wasn't 100% sure because I wasn't remember the steps.
Aristos
@Aristos: And that's why I didn't accept the answer right away, but only after trying it myself. Of course, one needs to omit the assembly file in the handler entry for it to work. And this is how to register the module programmatically: http://stackoverflow.com/questions/239802/programmatically-register-httpmodules-at-runtime
Quandary