题
我使用的传统Asp.Net网站,其中我使用的System.Web.Routing模块。我想在其中找到我知道路由的HTTP模块被加载与否的方法是什么?
解决方案
所有你需要知道的是模块的名称,你已经在你的web.config文件中配置 例如矿被命名为:“UrlRoutingModule”,你可以从这里这个片段看到(格式化的StackOverflow):
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule, System.Web.Routing,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
一旦你的,你需要做的是检查应用程序的模块性(这是你的模块名称类型HttpModuleCollection的,并确认它不是空。如果你想要做一些额外的检查可以检查的类型对象太(未示出)。
// From Global.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
if (Modules.AllKeys.Contains("UrlRoutingModules")
&& Modules["UrlRoutingModule"] != null)
{
// the module is loaded
}
}
不隶属于 StackOverflow