2009-02-22 4 views
7

특정 HttpModule이로드되었는지 프로그래밍 방식으로 확인하려는 중입니다. 작성중인 구성 요소가 올바르게 작동해야합니다.HttpModule이로드되었는지 감지

bool ismodulepresent = false; 
foreach(HttpModuleAction module in ((HttpModulesSection)ConfigurationManager.GetSection("system.web/httpModules")).Modules) 
{ 
    if(module.Type == typeof(MyModule).FullName) 
    { 
     ismodulepresent = true; 
     break; 
    } 
} 

을하지만 그것은 단지 IIS5.1 <httpModules> 섹션이 아닌 새로운 <system.webServer> 섹션 작동 : 내가 노력하고있어.

두 섹션을 모두 확인하는 것 외에 다른 방법을 사용하는 것이 더 좋은가요?

답변

12
HttpModuleCollection modules = HttpContext.Current.ApplicationInstance.Modules; 
foreach (string moduleKey in modules.Keys) 
{ 
    IHttpModule module = modules[moduleKey]; 
    // Do your check here 
} 
+0

감사합니다. –