tags:

views:

211

answers:

1

I'm going to use System.DirectoryServices to programatically add a wildcard filter for IIS (Version 5.0 and IIS 6.0).

Anyone have some food for thought? Thanks in advance!

+1  A: 

All you need to do is add the wild card to the metabase ScriptMap property of the site:

For example:

using (DirectoryEntry de = new DirectoryEntry("IIS://Localhost/W3SVC/2/ROOT"))
{
    de.Properties["ScriptMaps"].Add(
        @"*,c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll,0,GET,HEAD,POST");
    de.CommitChanges();
}

The example above maps the ASP.NET 2.0 ISAPI filter as the wild card filter.

Kev
Thanks! I've seen that before. And it CAN successfully add the filter. BUT, it unfortunately doesn't work on my machine. After deleting the filter and added it again, the filter works fine. Is that the matter of mask as the third part in your scripts? Thanks!
Roy
Okay, I got it. It is the extension I used, I use ".*" rather than "*"
Roy