How does ServerManager finds the states of an given site

3

I am trying to read the status of a site using Servermanager. Basically this is what I have,

var serverManager = new ServerManager(siteInstance.Server.ConfigPath);
    var site = serverManager.Sites.FirstOrDefault(x => x.Id == Convert.ToInt64(siteInstance.IisIdentifier));
    return site.State.ToString();

I am able to read the config file and site details without any issue. But the status of the site is either giving me COM error below or giving an status that doesn't reflect the actual status of the site in IIS.

The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)

To my understanding, config file only contains the site information. It doesn't indicate which IIS servers are reading from the config. So how does the ServerManager know which IIS to look into to look for the running status of the site?

c#
iis
configuration
iis-7.5
servermanager
asked on Stack Overflow Dec 11, 2012 by jack

2 Answers

1

The reason you are getting the site is because you are trying to read the status from site configuration file, which doesn't contain the state of the site. Instead, what you should be doing is connect directly to IIS server like this:

ServerManager manager= ServerManager.OpenRemote("testserver");
var site = manager.Sites.First();
var status = site.State.ToString() ;

Please refer to my post below for full details: Programmatically get site status from IIS, gets back COM error

answered on Stack Overflow Dec 12, 2012 by Jack • edited May 23, 2017 by Community
0

Checkout this site.. I googled the Execption plus error code and I think this should help to get you pointed in the right direction

The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)

if the article does not solve the problem or issue try the following.. also paste a snippet of what your .config file looks like as well..

Checked ApplicationPool in IIS Manager to verify that you have a DefaultAppPool. even though you don't use it, IIS still required it for some automation at times.

Looking at the system32\inetsrv\config\applicationHost.config or through your IIS Managment UI.

ex:

<applicationPools>  
        <add name="DefaultAppPool" />  
      <add name="Classic .NET AppPool" managedPipelineMode="Classic" />         <applicationPoolDefaults>    
          <processModel identityType="ApplicationPoolIdentity" />                     </applicationPoolDefaults>
</applicationPools>
answered on Stack Overflow Dec 11, 2012 by MethodMan

User contributions licensed under CC BY-SA 3.0