title: IIS: How to get the Metabase path?
body: <p>i'm trying to get the list of mime types known to an IIS server (<a href="https://stackoverflow.com/questions/174888/asp-net-iis6-how-to-search-the-servers-mime-map">which you can see was asked and and answered by me 2 years ago</a>). The copy-pasted answer involves:</p>
  
  <p><code>GetObject("IIS://LocalHost/MimeMap")</code> <a href="http://msdn.microsoft.com/en-us/library/ms752346.aspx" rel="nofollow noreferrer">msdn</a></p>
  
  <p><code>GetObject("IIS://localhost/mimemap")</code> <a href="http://support.microsoft.com/kb/246068" rel="nofollow noreferrer">KB246068</a></p>
  
  <p><code>GetObject("IIS://localhost/MimeMap")</code> <a href="http://www.hanselman.com/blog/ProgrammaticallyAddingMimeTypesToIIS.aspx" rel="nofollow noreferrer">Scott Hanselman's Blog</a></p>
  
  <p><code>new DirectoryEntry("IIS://Localhost/MimeMap"))</code> <a href="https://stackoverflow.com/questions/174888/asp-net-iis6-how-to-search-the-servers-mime-map">Stack Overflow</a></p>
  
  <p><code>new DirectoryEntry("IIS://Localhost/MimeMap"))</code> <a href="https://stackoverflow.com/questions/234526/can-i-setup-an-iis-mime-type-in-net">Stack Overflow</a></p>
  
  <p><code>New DirectoryServices.DirectoryEntry("IIS://localhost/MimeMap")</code> <a href="http://www.velocityreviews.com/forums/t83319-querying-iismimemap-access-is-denied-help.html" rel="nofollow noreferrer">Velocity Reviews</a></p>
  
  <hr>
  
  <p>You get the idea. Everyone agrees that you use a magical path <strong>iis://localhost/mimemap</strong>. And this works great, except for the times when it doesn't.</p>
  
  <p>The only clue i can find as to why it fails, <a href="http://blog.crowe.co.nz/archive/2006/06/02/647.aspx" rel="nofollow noreferrer">is from an IIS MVP, Chris Crowe's, blog</a>:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>There are two clues here:</p>
  
  <ol>
  <li>He calls <code>iis://localhost/mimemap</code> the <strong>Metabase Path</strong>. Which sounds to me like it is some sort of "<em>path</em>" to a "<em>metabase</em>".</li>
  <li>He says that the <em>path</em> to the <em>metabase</em> could be something else; and he gives an example of what it could be like.</li>
  </ol>
  
  <p>Right now i, and the entire planet, are hardcoding the "<strong>MetabasePath</strong>" as </p>
  
  <pre><code>iis://localhost/MimeMap
  </code></pre>
  
  <p>What should it really be? What should the code be doing to construct a valid MetabasePath?</p>
  
  <hr>
  
  <p>Note: i'm not getting an access denied error, the error is the same when you have an invalid MetabasePath, e.g. <code>iis://localhost/SoTiredOfThis</code></p>