Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't agree with you. I coded up a test app and I get the correct AppPool name from it, even if I set the AppPool manually using IIS Manager. </p> <p>To make sure, I have tested once, name name was ok; then, I popep up the IIS Manager, changed the AppPool, executed <code>iisreset</code>, and ran the test app again - the AppPool name I got was correct again. I don't how your code looked like, but mine is like this:</p> <pre><code>using System; using System.IO; using System.DirectoryServices; class Class { static void Main(string[] args) { DirectoryEntry entry = FindVirtualDirectory("&lt;Server&gt;", "Default Web Site", "&lt;WantedVirtualDir&gt;"); if (entry != null) { Console.WriteLine(entry.Properties["AppPoolId"].Value); } } static DirectoryEntry FindVirtualDirectory(string server, string website, string virtualdir) { DirectoryEntry siteEntry = null; DirectoryEntry rootEntry = null; try { siteEntry = FindWebSite(server, website); if (siteEntry == null) { return null; } rootEntry = siteEntry.Children.Find("ROOT", "IIsWebVirtualDir"); if (rootEntry == null) { return null; } return rootEntry.Children.Find(virtualdir, "IIsWebVirtualDir"); } catch (DirectoryNotFoundException ex) { return null; } finally { if (siteEntry != null) siteEntry.Dispose(); if (rootEntry != null) rootEntry.Dispose(); } } static DirectoryEntry FindWebSite(string server, string friendlyName) { string path = String.Format("IIS://{0}/W3SVC", server); using (DirectoryEntry w3svc = new DirectoryEntry(path)) { foreach (DirectoryEntry entry in w3svc.Children) { if (entry.SchemaClassName == "IIsWebServer" &amp;&amp; entry.Properties["ServerComment"].Value.Equals(friendlyName)) { return entry; } } } return null; } } </code></pre> <p>Sorry for my lousy english.<br> Hope I've helped.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload