Mostly for my own notes for when I next need to do this again. Assumes that the HttpModule has already been compiled and that you have the DLL.
Copy the DLL to the server and put in any folder.
Install the module into the GAC
- Right click on a command window and select "Run as administrator"
- At the command prompt type "explorer c:\windows\assembly" without the quotes.
- 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".
- Drag the HttpModule DLL from the new window and drop it into the c:\windows\assembly window.
- The HttpModule is now installed in the GAC.
Add the module to IIS 7.5
(This assumes a .NET 2.0 module (there's a good reason why it's .NET 2.0 and not 4))
- 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.
- In the Features View find the IIS section and double click on Modules.
- Click "Add Managed Module"
- In the Name field put any name you want.
- In the Type dropdown you should find the module that you added to the GAC above. Select this.
- Leave the "Invoke only for requests to ASP.NET applications or managed handlers" unchecked.
- Click OK and you're done.
This HttpModule will now execute against every request on all web sites.
What is the reason for using a .NET 2.0 vs .NET 4.0 module?
ReplyDeleteBy default IIS 7.5 loads the module with the 2.0 runtime. To load using the 4.0 runtime use the appcmd command line tool with the runtimeVersionv4.0 precondition
ReplyDelete%windir%\system32\inetsrv\appcmd add module /name:MyModule /type:MyAssembly.MyModule, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxx /preCondition:runtimeVersionv4.0