I want to manage IIS (versions 7-10) by using C# ServerManager сlass.
Locally GetAdministrationConfiguration method returns 1 section group and 2 sections in administration config (see code below).
But on remote server there are 0 section groups and 0 sections.
Source code (need to add Microsoft.Web.Administration in "Extensions" references of C# project):
using Microsoft.Web.Administration;
using System;
namespace ConsoleApp7
{
class Program
{
static void Main(string[] args)
{
using (var iisManager = new ServerManager())
{
var c = iisManager.GetAdministrationConfiguration();
Console.WriteLine(c.RootSectionGroup.SectionGroups.Count);
Console.WriteLine(c.RootSectionGroup.Sections.Count);
}
Console.ReadKey();
}
}
}
- Local machine: Win10, IIS 10.0, .NET framework 4.7.1.
- Remote server #1: Win2008R2, IIS 7.5, .NET framework 4.7.2.
- Remote server #2: Win7, IIS 7.5, .NET framework 4.5.2.
On all machines C:\Windows\System32\inetsrv\Config\administration.config is avaliable and contains all needed sections.
How to get administration configuration of IIS on remote servers?
administration.configcan be safely ignored, as it is the configuration for IIS Manager (which has little to do with the sites/applications).