23 February 2007 in .Net, Code, Microsoft, Tools, Windows | Comments enabled
I’ve been developing an ASP.NET solution and was starting to get some odd behavior on my development machine (Vista Ultimate). We’ve written a custom HttpHandler for managing user authorisation and when running the solution up against the ASP.NET Cassini web server (the “built in web server”) everything ran fine however when running against IIS7 authorisation wasn’t working correctly. Some debugging and it became evident that the handler wasn’t even executing when running within IIS7.
IIS7 provides a whole swag of great new functionality so after some hunting around I found that the module wasn’t registered with IIS7.
How do you register a custom module in IIS7?
Fire up IIS Manager
Select your website you want to add the module for (IIS will inspect the Web.config of the site to get the modules)
Open up “Modules”:
You should find that your modules will be of Module Type “Managed” if you’re writing them in .NET, check it’s not already listed
Click “Add Managed Module…” on the Action pane
Type in the name of your module and select it from the drop down list (IIS will populate this from what it finds in the web site, if the module isn’t listed then you’ve made a mistake somewhere
Click OK and you should now find that your custom HttpModule works
Another way
Some of you will already know that IIS7 configuration is now XML and you can configure IIS7 from the web.config. This was recently demonstrated at a local .NET User Group in Wellington by Jeremy. It’s a pretty kick ass change from how things work in IIS6 and earlier and makes explaining some of these things easier. After adding the Module reference I noticed Visual Studio warned me that the Web.config file had changed so I took a look at what it had changed and, sure enough:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="CustomAuthModule"
type="Mindscape.ResearchProject.Website.Infrastructure.CustomAuthModule" />
</modules>
</system.webServer>
So you could just drop this block into your Web.config and get the same module registration that I detailed earlier. Fantastic.
- JD
3 comments. Add your own comment.
Smatte says 30 March 2007 @ 00:31
Do you know what is the equivalent option in II6 of “Check that file exists” in IIS7?
Sergio says 24 August 2007 @ 04:51
Did you ever figure out what is the IIS7 equivelent of “Check that file exists”? I can’t seem to find it either and there is no documentation on it.
traskjd says 25 August 2007 @ 13:37
Sorry guys, I still haven’t found anything about it. When I have googled I found a link to the iis forums but they seem to be down
– JD
Leave a Comment