Current application pool name

1

I am trying to get the current application pool name of a web application. I googled a lot and I found several ways to do it but none of them seems to work for me This is one of my implementations:

   private static string GetCurrentApplicationPoolId()
    {
        string virtualDirPath = AppDomain.CurrentDomain.FriendlyName;
        virtualDirPath = virtualDirPath.Substring(4);
        int index = virtualDirPath.Length + 1;
        index = virtualDirPath.LastIndexOf("-", index - 1, index - 1);
        index = virtualDirPath.LastIndexOf("-", index - 1, index - 1);
        virtualDirPath = "IIS://localhost/" + virtualDirPath.Remove(index);
        DirectoryEntry virtualDirEntry = new DirectoryEntry(virtualDirPath);
        return virtualDirEntry.Properties["AppPoolId"].Value.ToString();
    }

I get as an error: Unknown error (0x80005000)

c#
asp.net
security
iis
application-pool
asked on Stack Overflow May 28, 2014 by user3679520 • edited Jun 7, 2014 by Benjamin

1 Answer

0

Control panel - program features - turn on off - look for IIS 6 compatibily and check everything.

answered on Stack Overflow May 28, 2014 by Robert P

User contributions licensed under CC BY-SA 3.0