Programmatically register HttpModules at runtime

前端 未结 5 1787
深忆病人
深忆病人 2020-12-02 11:29

I\'m writing an app where 3rd party vendors can write plugin DLLs and drop them into the web app\'s bin directory. I want the ability for these plugins to be able to registe

5条回答
  •  盖世英雄少女心
    2020-12-02 12:01

    In new versions of ASP MVC you can use Package Manager to add a reference to WebActivatorX and then do something like this

    using WhateverNameSpacesYouNeed;
    
    [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(YourApp.SomeNameSpace.YourClass), "Initialize")]
    namespace YourApp.SomeNameSpace
    {
      public static void Initialize()
      {
        DynamicModuleUtility.RegisterModule( ... the type that implements IHttpModule ... );
      }
    }
    

提交回复
热议问题