HttpModules and Global.aspx

A couple of things are important to note about the Global.aspx file with regard to HttpModules. First, the Global.aspx file can handle any of the HttpApplication events that are exposed to the HttpModules. Second, events generated in an HttpModule can be handled in the Global.aspx file.

All events in HttpModules are automatically exposed when the module is registered upon the application starting. To handle the event, you must write an appropriate event handler that needs to be named as follows when the handler is in a script block of the Global.aspx file:

 // C# public FriendlyModuleName_OnEventName(appropriate_event_argument_signature) { //Do something here } 'VB Public Sub FriendlyModuleName_OnEventName(appropriate_event_argument_signature) ...

Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.