IIS: How to get the Metabase path?

Posted by Ian Boyd on Stack Overflow See other posts from Stack Overflow or by Ian Boyd
Published on 2010-04-26T20:18:17Z Indexed on 2010/04/27 17:13 UTC
Read the original article Hit count: 434

Filed under:
|
|
|

i'm trying to get the list of mime types known to an IIS server (which you can see was asked and and answered by me 2 years ago). The copy-pasted answer involves:

GetObject("IIS://LocalHost/MimeMap") msdn

GetObject("IIS://localhost/mimemap") KB246068

GetObject("IIS://localhost/MimeMap") Scott Hanselman's Blog

new DirectoryEntry("IIS://Localhost/MimeMap")) Stack Overflow

new DirectoryEntry("IIS://Localhost/MimeMap")) Stack Overflow

New DirectoryServices.DirectoryEntry("IIS://localhost/MimeMap") Velocity Reviews


You get the idea. Everyone agrees that you use a magical path iis://localhost/mimemap. And this works great, except for the times when it doesn't.

The only clue i can find as to why it fails, is from an IIS MVP, Chris Crowe's, blog:

string ServerName = "LocalHost";
string MetabasePath = "IIS://" + ServerName + "/MimeMap";
    // Note: This could also be something like
    // string MetabasePath = "IIS://" + ServerName + "/w3svc/1/root";

DirectoryEntry MimeMap = new DirectoryEntry(MetabasePath);

There are two clues here:

  1. He calls iis://localhost/mimemap the Metabase Path. Which sounds to me like it is some sort of "path" to a "metabase".
  2. He says that the path to the metabase could be something else; and he gives an example of what it could be like.

Right now i, and the entire planet, are hardcoding the "MetabasePath" as

iis://localhost/MimeMap

What should it really be? What should the code be doing to construct a valid MetabasePath?


Note: i'm not getting an access denied error, the error is the same when you have an invalid MetabasePath, e.g. iis://localhost/SoTiredOfThis

© Stack Overflow or respective owner

Related posts about iis

Related posts about metabase