Click here to Skip to main content
Click here to Skip to main content

How to get list of all active HttpModules in ASP.NET?

, 8 Jun 2010
Rate this:
Please Sign up or sign in to vote.
Get list of all active HttpMoudles in ASP.NET
Here is a quick tips to get the list of all active HTTPModules at runtime. We can get the list of all HttpModules from the web.config or from machine.config file. But, what we need to do if we want to get the list of all active HttpModules during runtime? Yes. We can easily get the details with the help of HttpApplication and HttpModuleCollection Class. If we quickly recall the IIS Process Request, when a request reaches to worker Process from client browser, First of all Worker process is responsible to start and HttpRuntime by loading ISAPI filter. After that HttpRuntime load an HttpApplication object with the help of HttpApplicationFactory class. Each and every request should pass through the corresponding HTTPModule to reach to HTTPHandler, this list of module are configured by the HTTPApplication. Below is the code snippet by which we can get the list of active HttpModules.
 
//Get Application Instance from Current Content
       HttpApplication httpApps = HttpContext.Current.ApplicationInstance;
       //Get List of modules
       HttpModuleCollection httpModuleCollections = httpApps.Modules;
       Response.Write("Total Number Active HttpModule : " + httpModuleCollections.Count.ToString() + "</br>");
       Response.Write("<b>List of Active Modules</b>" + "</br>");
       foreach (string activeModule in httpModuleCollections.AllKeys)
       {
           Response.Write(activeModule + "</br>");
       }
Below is the sample output :

 
This can be quite useful when we want to check if our custom created module loaded successfully or not .

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Abhijit Jana
Technical Lead
India India
.NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker | Geek | Blogger | Husband
 
Blog : http://abhijitjana.net
Web Site : http://dailydotnettips.com
Twitter : @AbhijitJana
My Kinect Book : Kinect for Windows SDK Programming Guide
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 8 Jun 2010
Article Copyright 2010 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid