2

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!

Kev
  • 118,037
  • 53
  • 300
  • 385
Roy
  • 2,313
  • 6
  • 37
  • 46

1 Answers1

4

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
  • 118,037
  • 53
  • 300
  • 385
  • 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 Sep 29 '09 at 02:54
  • Okay, I got it. It is the extension I used, I use ".*" rather than "*" – Roy Sep 29 '09 at 08:35