Question

I am using the traditional Asp.Net website in which I am using the System.Web.Routing module. I want to find the way in which I know that the routing http modules is loaded or not?

Was it helpful?

Solution

All you need to know is the module's name as you have it configured in your web.config file for example mine is named: "UrlRoutingModule" as you can see from this snippet here (formatted for StackOverflow):

    <add name="UrlRoutingModule" 
         type="System.Web.Routing.UrlRoutingModule, System.Web.Routing,
         Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

once you have that, all you need to do is check the application's Modules property (which is of type HttpModuleCollection for your module's name and verify that it's not null. If you want to do some extra checking you can check the type of the object too (not shown).

// From Global.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
    if (Modules.AllKeys.Contains("UrlRoutingModules") 
        && Modules["UrlRoutingModule"] != null)
    {
        // the module is loaded
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top