I am writing a httpModule and the plan is to attach the module to PreRequestHandlerExecute event, while I see that there is already existing module attached to the same event.
My question what would be the order of execution of httpModules which are registered to the same event ?
Is there a way I can make control the order of execution of httpModules if they are registered to the same event in this case PreRequestHandlerExecute ?
According to ASP.NET forum: ASP.NET Fires http modules the order they are defined in the web.config.
Please also pay attention to this comment (same forum post):
As somebody else pointed out you should never rely on the order of modules in the chain.
If you have dependencies and specific orders you need to handle in your own modules then you probably need to consolidate those modules into a single module and handle the order through your own code internally.
by rstrahl.
I fully agree with this point, so you should keep your module as independent as possible.