简体   繁体   中英

How do I found the routing http modules loaded?

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?

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
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM