0

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?

1
  • If your goal is to "manage IIS", then administration.config can be safely ignored, as it is the configuration for IIS Manager (which has little to do with the sites/applications). Commented Feb 19, 2019 at 15:26

1 Answer 1

0

Solved! Based on MSDN question I unchecked "Prefer 32-bit" in C# project properties and configuration is received now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.