Here I will give you a quick trick to get the list of all active HttpModules at runtime. We can get all the HttpModules from web.config or from machine.config file. But, If we want this at runtime then we can do this with the help of HttpApplication and HttpModuleCollection class. Below is the code snippet for getting the list of all active HttpModules
.
Below is the sample output-
.
//Get Application Instance from Current
Content
HttpApplication httpApps = HttpContext.Current.ApplicationInstance;
//Get List of modules in module collections
HttpModuleCollection httpmodules = httpApps.Modules;
Response.Write("Total
Number Active HttpModule : " + httpmodules.Count.ToString() + "</br>");
Response.Write("<b>List
of Active Modules</b>" + "</br>");
foreach (string activeModule in httpmodules.AllKeys)
{
Response.Write(activeModule
+ "</br>");
}
No comments:
Post a Comment