2

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 ?

Dibyendu
  • 55
  • 1
  • 9

1 Answers1

3

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.

ntl
  • 1,289
  • 1
  • 10
  • 16
  • I know that is true for httpHandlers because the httpHandlers are getting hooked up through web.config but httpModules are hooked up through httpApplication events, which can be anything from : http://stackoverflow.com/questions/441421/httpmodule-event-execution-order After the registrations against the event the which should be the first deciding factor when the module gets triggered does the sequence of httpModule matter at all ? – Dibyendu Aug 20 '14 at 20:35
  • When some application event appeared, modules will be searched in order that they are defined in web.config and if event handler method for specific event exists it will be used to process it. – ntl Aug 20 '14 at 20:38
  • Thanks I appreciate the answer here. – Dibyendu Aug 24 '14 at 20:32