Skip to main content

Install and verify IIS HttpModules with custom config sections

A week ago I started to learn about HttpModules and HttpHandlers watching a pluralsight course by Robert Boedigheimer. First of all I want to really recommend this course, I learned a lot of stuff which I could not find in any other course, book or blog post.

As I already did in the past with another course, I want to add some comments and extend the HttpModule part. I refer to the course example with the serverMaskModuleGAC.

I walked into some trap doors and thereby I found another approach to simplify the installation process of the module to GAC a little bit. With this approach I am able to verify my custom config sections and module registration is correct.

Here is my approach:

1. When you have finished your implementation for serverMaskModule, install it in the GAC as usual by using the gacutil tool. By the way, there are some traps when you need to install it on Windows Server 2012. Here I am using Windows 8.1 64 Bit. I created my HttpModule with .NET 2.0 because it seems to be more compatible with different IIS and Windows versions. On Windows Server 2012 I was not able to install it with .NET version 4.5.

2. Copy your custom config section schema into the folder C:\Windows\System32\inetsrv\config\schema

3. Add the custom config section in applicationHost.config

4. Register your module by using IIS Manager. Click on the server node, and choose Modules:


5. Click "Add Managed Module"


6. Click again on the server node and choose Configuration Editor


7. Choose the serverMaskedModule section


8. For testing purposes choose another value for header filter (In my implementation I have changed the parameter name from "name="serverMaskModuleGACHeaders" to "headerFilter"):


As long as the value is shown in normal print, it is the default value coming from the custom config section. When you change the value it will be bold printed, IIS Manager will add the config section in the applicationHost.config file.

9. If you did not get any error messages so far you can start sending your first test requests to verify the module is working and filtering the headers you have chosen in the in the serverMaskModule section.

The advantage of this approach is you can test and verify, that module registration and your custom config is validated. E.g. when you have a spelling mistake in your config section you will get an error messages like this:



Comments

Popular posts from this blog

How to delete Azure Active-Directories

When I was trying to delete an Azure Active-irectory by using the management portal I have received the error message “Directory contains one or more applications that were added by a user or administrator” and I was really confused.

Then I found out this is a common issue. The solution was even more confusing, some PowerShell cmdlets are needed. Unfortunately I was not able to proceed, it was not possible to login with my Microsoft-ID to execute the needed commands.

Here I found out I have to install the correct version of the tools. These are located here.

Clean up AppFabric Dashboard Part 2: Duplicate collection entry in Web.config

In Part one I have already described how to remove phantom apps here on more supplement. These phantom apps could also remain in the AppFabric Monitoring db:


Just delete no longer needed entries in this table.
Duplicate collection entry When you receive this kind of issue, like "[...] Cannot add duplicate collection entry [...]" you have defined the a configuration section twice in two different Web.config files in different places in your file system.

Clear One easy solution is to use a clear statement. Searching for the inherited element There is a post in Microsoft's documentation which is explaining how to do it. Visual Studio in debug mode When you are working with Visual Studio in debug mode, which means you are just pressing F5 to run it on your local IIS instead of publishing it to a web server, you should keep in mind that e.g. your obj folder might contain more copies of your Web.config file. This could lead into this duplicate collection issue as well.

How to move iTunes library to NAS folder

This is nothing new, but to free up some space on my MacBook I decided to move my iTunes library to a network drive on my NAS. I got some inspiration from this old German video. I tried to collect all relevant information for doing so.
I did it by following this steps I closed iTunesI mounted a network drive with AFPI copied my iTunes library folder to a folder on the network drive (it is important to keep the folder name "iTunes"!) I opened iTunes while pressing the "alt" key. Now you can create a library or choose one from another location I set the new iTunes folderI deleted the local iTunes library My iTunes settings look like this now, iTunes took over the selected folder: Keep in mind the followingYou cannot open the iTunes library with two accounts at the same time.When you choose to set "Keep iTunes Media folder organized" iTunes will set your folder structure for artists an albums and also the file pattern for your songs. You have to think about th…