none
Can't load HttpModule in GAC RRS feed

  • Question

  • I write a HttpModule in .Net 3.5 and trying to install on the server root of IIS 10 server. I use gacutil.exe v7.0A successfully install it and I use /l command confirm that my module exists. I add configuration below to C:\Windows\System32\inetsrv\config\applicationHost.config:

    <add name="ModuleModEF35" type="ModuleModEF35.MyModule, ModuleModEF35" preCondition="managedHandler" />

    And I got FileNotFoundException when i browsed the child website. Due to some reasons, I can't place my module in the individual \bin folder though I know it definitely works.

    namespace ModuleModEF35
    {
        class MyModule : System.Web.IHttpModule
        {
            void IHttpModule.Dispose()
            {
    
            }
            void IHttpModule.Init(HttpApplication context)
            {
                context.BeginRequest += Context_BeginRequest;
            }
            private void Context_BeginRequest(object sender, EventArgs e)
            {
                HttpContext context = HttpContext.Current;
                if (context.Request.RawUrl.Contains("%EF"))
                {
                    context.Response.Redirect("https://http.cat/403");
                    context.Response.End();
                }
    
            }
        }
    }

    Thursday, November 21, 2019 3:58 AM

All replies

  • Hi Kungfury9803,

    Welcome to MSDN forum.

    According to your description, I suggest you could firstly modify your module tag with adding Version, Culture & PublicKeyToken in <modules> section like below:

          <addname="HelloWorldModule"type="HelloWorldModule, MyAssembly, Version=1.2.3.3, Culture=neutral, PublicKeyToken=t76u8k8k66h70v4h"/>

    In addition, it seems that if you don’t add these things, it will load the module from the bin folder instead of the GAC.

    Besides, I suggest you could refer to below steps to make sure you have add the module into the GAC well.

    #1. Right click on a command window and select "Run as administrator"

    #2. At the command prompt type "explorer c:\windows\assembly" without the quotes.

    #3. Find the folder that you copied the DLL to and while holding down the control key right click this folder and select "Open in a new window".

    #4. Drag the HttpModule DLL from the new window and drop it into the c:\windows\assembly window.

    #5. The HttpModule is now installed in the GAC.

    #6. Add the module to IIS

    #7. Open IIS and navigate to root. This is usually the machine name and adding the module here will ensure that it operates on all websites.

    #8. In the Features View find the IIS section and double click on Modules.

    #9. Click "Add Managed Module"

    #10. In the Name field put any name you want.

    #11. In the Type dropdown you should find the module that you added to the GAC above. Select this.

    #12. Leave the "Invoke only for requests to ASP.NET applications or managed handlers" unchecked.

    #13. Then click OK and you're done.

    Hope all above will help you.

    Best Regards,

    Anna 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Friday, November 22, 2019 6:46 AM
  • Hi Kungfury9803

    Sorry to disturb you.

    Did you have any update? Please let me know if the issue persists.

    If the issue is achieved, could you share your solution to others?

    If not, please feel free to contact us, we will try our best to help you.

    Have a nice day.

    Best Regards,

    Anna 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, November 29, 2019 8:12 AM