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?

jack
  • 33
  • 4
  • Does your site utilize virtual Directory..? this would be my first place to check along with AppPool.. – MethodMan Dec 11 '12 at 05:51
  • what do you mean by utility virtual Directory? Can you elaborate on that please? I've check the AppPool, it's the same thing, I can see all AppPool details, but when trying to get state, it's either given me error or incorrect state – jack Dec 11 '12 at 05:53

2 Answers2

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

Community
  • 1
  • 1
Jack
  • 2,600
  • 23
  • 29
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>
MethodMan
  • 18,625
  • 6
  • 34
  • 52
  • my case is different to one in the link. The site is running fine on the IIS. It's only when I am trying to access the site status through ServerManager code, that's when I am getting the error. I am getting a feeling that it's pointing to the wrong IIS server, which would explain this whole thing – jack Dec 11 '12 at 06:05
  • It could be that ..or it could be a Permissions issue in regards to Password for example.. can you show a bit more code does the site require user domain name and Password..? – MethodMan Dec 11 '12 at 06:08
  • Thanks for your help. Unfortunately, I am not able to vote up on your post. – jack Dec 11 '12 at 06:09
  • Was the information helpful in regards to helping you correct your issues Jack..? – MethodMan Dec 11 '12 at 06:10
  • That's all the code I used to access the site status. I know there is permission invovled in reading the config file. That's been resolved. – jack Dec 11 '12 at 06:10
  • Well, not exactly, but I do appreciate people spending time in answering other people's question. – jack Dec 11 '12 at 06:12