%3CLINGO-SUB%20id%3D%22lingo-sub-875840%22%20slang%3D%22en-US%22%3ErunAllManagedModulesForAllRequests%20is%20conflicting%20with%20skipManagedModules%20and%20taking%20precedence%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-875840%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EAs%20of%20this%20writing%2C%20when%20HTTP%20module%20is%20enabled%2C%20the%20warming%20HTML%20page%20defined%20in%20AppInt%20module%20may%20not%20load%20properly.%20Good%20news%20is%2C%20there%20is%20a%20workaround%20%3C%2FFONT%3Ewhich%20is%20to%20place%20the%20managed%20module%20onto%20the%20GAC%20to%20have%20the%20warming%20page%20shown%20correctly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFYI%2C%20for%20the%20right%20testing%2C%20you%20need%20to%20recycle%20IIS%20apppool%20first.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20how%20you%20can%20make%20a%20test%2Fsample%20managed-module%20and%20place%20it%20in%20the%20GAC%20(code%20sample%20is%20placed%20at%20the%20end%20of%20this%20blog).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EBuild%20MyIIS7Procject.dll%20from%20the%20Developer%20Command%20Prompt%20for%20VS%202019%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CLI-WRAPPER%3E%3C%2FLI-WRAPPER%3E%3C%2FP%3E%0A%3CP%3Emd%20c%3A%5Ctemp%5Cdev%3C%2FP%3E%0A%3CP%3Ecd%20c%3A%5Ctemp%5Cdev%3C%2FP%3E%0A%3CP%3Ecreate%20C%3A%5Ctemp%5Cdev%5Ctestmodule.cs%3C%2FP%3E%0A%3CP%3Esn%20-k%20mytestkey.snk%3C%2FP%3E%0A%3CP%3E%5Cwindows%5CMicrosoft.NET%5CFramework%5Cv4.0.30319%5Ccsc.exe%20%2Ft%3Alibrary%20%2Fout%3AC%3A%5Ctemp%5Cdev%5CMyIIS7Project.dll%20%2Fdebug%20C%3A%5Ctemp%5Cdev%5Ctestmodule.cs%20%2Fr%3ASystem.Web.dll%20%2Fkeyfile%3AC%3A%5Ctemp%5Cdev%5Cmytestkey.snk%3C%2FP%3E%0A%3CP%3Egacutil%20%2Fuf%20MyIIS7Project%3C%2FP%3E%0A%3CP%3Egacutil%20%2Fi%20C%3A%5Ctemp%5Cdev%5CMyIIS7Project.dll%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet%20the%20path%20of%20MyIIS7Project%20in%20GAC%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CLI-WRAPPER%3E%3C%2FLI-WRAPPER%3E%3C%2FP%3E%0A%3CP%3Egacutil%20%2Fl%20MyIIS7Project%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22737%22%3E%3CP%3EC%3A%5Ctemp%5Cdev%26gt%3B%5Ctools%5CAmd64%5Cgacutil.exe%20%2Fl%20MyIIS7Project%3C%2FP%3E%0A%3CP%3EMicrosoft%20(R)%20.NET%20Global%20Assembly%20Cache%20Utility.%26nbsp%3B%20Version%204.0.30319.1%3C%2FP%3E%0A%3CP%3ECopyright%20(c)%20Microsoft%20Corporation.%26nbsp%3B%20All%20rights%20reserved.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Global%20Assembly%20Cache%20contains%20the%20following%20assemblies%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20MyIIS7Project%2C%20Version%3D0.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D63d950d99899da73%2C%20processorArchitecture%3DMSIL%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EOpen%20%25windir%25%5Csystem32%5Cinetsrv%5Cconfig%5Capplicationhost.config%20and%20put%20the%20below%20line%20at%20the%20bottom%20of%20existing%20%3CMODULE%3E%20section.%3C%2FMODULE%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CLI-WRAPPER%3E%3C%2FLI-WRAPPER%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CADD%20name%3D%22%26quot%3BTestModule%26quot%3B%22%20type%3D%22%26quot%3B%26lt%3BSTRONG%22%3E%3CFONT%20color%3D%22%230000ff%22%3EMyModule.TestHttpModule%3C%2FFONT%3E%2C%20%3CSTRONG%3E%3CFONT%20color%3D%22%23993366%22%3EMyIIS7Project%2C%20Version%3D0.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D63d950d99899da73%3C%2FFONT%3E%3C%2FSTRONG%3E%22%20preCondition%3D%22managedHandler%2CruntimeVersionv4.0%22%20%2F%26gt%3B%3C%2FADD%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENOTE%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3E%3CFONT%20color%3D%22%230000ff%22%3Ethe%20first%20part%3C%2FFONT%3E%3C%2FSTRONG%3E%20of%20type%20is%20from%20the%20class%20name%20in%20the%20dll%20file%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CFONT%20color%3D%22%23993366%22%3Ethe%20second%20part%3C%2FFONT%3E%3C%2FSTRONG%3E%20is%20the%20path%20in%20GAC%20after%20removing%20%E2%80%9CprocessorArchitecture%3DMSIL%E2%80%9D%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3ECode%20sample%3A%3C%2FU%3E%3C%2FP%3E%0A%3CP%3EAnd%20here%20is%20the%20sample%20source%20code%20for%20the%20testmodule.cs%3A%3C%2FP%3E%0A%3CP%3E%2F*%3C%2FP%3E%0A%3CP%3EContent%20of%20testmodule.cs%3C%2FP%3E%0A%3CP%3E*%2F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eusing%20System%3B%3C%2FP%3E%0A%3CP%3Eusing%20System.Collections.Generic%3B%3C%2FP%3E%0A%3CP%3Eusing%20System.Text%3B%3C%2FP%3E%0A%3CP%3Eusing%20System.Web%3B%3C%2FP%3E%0A%3CP%3Enamespace%20MyModule%3C%2FP%3E%0A%3CP%3E%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20public%20class%20TestHttpModule%20%3A%20IHttpModule%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20public%20void%20Init(HttpApplication%20context)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20context.BeginRequest%20%2B%3D%20context_AddHeaders%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20void%20context_AddHeaders(object%20sender%2C%20EventArgs%20e)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bvar%20httpApplication%20%3D%20sender%20as%20HttpApplication%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if%20(httpApplication%20!%3D%20null)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20HttpContext%20context%20%3D%20((HttpApplication)sender).Context%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if%20(context.Request.ServerVariables%5B%22APP_WARMING_UP%22%5D%20%3D%3D%20%221%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20context.Response.AddHeader(%22AppInitTest%22%2C%20%22The%20request%20is%20called%20during%20IIS%20Appinit%20is%20on%20processing!!!%22)%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20else%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20context.Response.AddHeader(%22AppInitTest%22%2C%20Environment.MachineName)%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20public%20void%20Dispose()%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-875840%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EAs%20of%20this%20writing%2C%20when%20HTTP%20module%20is%20enabled%2C%20the%20warming%20HTML%20page%20defined%20in%20AppInt%20module%20may%20not%20load%20properly.%20Good%20new%20is%2C%20there%20is%20a%20workaround!%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

As of this writing, when HTTP module is enabled, the warming HTML page defined in AppInt module may not load properly. Good news is, there is a workaround which is to place the managed module onto the GAC to have the warming page shown correctly.

 

FYI, for the right testing, you need to recycle IIS apppool first.

 

Here is how you can make a test/sample managed-module and place it in the GAC (code sample is placed at the end of this blog).

 

Build MyIIS7Procject.dll from the Developer Command Prompt for VS 2019

md c:\temp\dev

cd c:\temp\dev

create C:\temp\dev\testmodule.cs

sn -k mytestkey.snk

\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library /out:C:\temp\dev\MyIIS7Project.dll /debug C:\temp\dev\testmodule.cs /r:System.Web.dll /keyfile:C:\temp\dev\mytestkey.snk

gacutil /uf MyIIS7Project

gacutil /i C:\temp\dev\MyIIS7Project.dll

 

Get the path of MyIIS7Project in GAC

gacutil /l MyIIS7Project

 

C:\temp\dev>\tools\Amd64\gacutil.exe /l MyIIS7Project

Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1

Copyright (c) Microsoft Corporation.  All rights reserved.

 

The Global Assembly Cache contains the following assemblies:

  MyIIS7Project, Version=0.0.0.0, Culture=neutral, PublicKeyToken=63d950d99899da73, processorArchitecture=MSIL

 

 

 

Open %windir%\system32\inetsrv\config\applicationhost.config and put the below line at the bottom of existing <module> section.

 

<add name="TestModule" type="MyModule.TestHttpModule, MyIIS7Project, Version=0.0.0.0, Culture=neutral, PublicKeyToken=63d950d99899da73" preCondition="managedHandler,runtimeVersionv4.0" />

 

NOTE:

  1. the first part of type is from the class name in the dll file
  2. the second part is the path in GAC after removing “processorArchitecture=MSIL”

 

Code sample:

And here is the sample source code for the testmodule.cs:

/*

Content of testmodule.cs

*/

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Web;

namespace MyModule

{

    public class TestHttpModule : IHttpModule

    {

        public void Init(HttpApplication context)

        {

            context.BeginRequest += context_AddHeaders;

        }

        void context_AddHeaders(object sender, EventArgs e)

        {

            var httpApplication = sender as HttpApplication;

            if (httpApplication != null)

            {

                HttpContext context = ((HttpApplication)sender).Context;

                if (context.Request.ServerVariables["APP_WARMING_UP"] == "1")

                {

                    context.Response.AddHeader("AppInitTest", "The request is called during IIS Appinit is on processing!!!");

                }

                else

                {

                    context.Response.AddHeader("AppInitTest", Environment.MachineName);

                }

            }

        }

        public void Dispose()

        {

        }

    }

}