.netiisservermanager

Why can't I see IIS sites I have added programmatically in inetmgr?


So, I have created a bunch of sites like so:

var manager = new ServerManager();
var binding = "*:80:" + Binding.Text;
var appPool = manager.ApplicationPools.Add(SiteName.Text);
appPool.ManagedRuntimeVersion = "v4.0";

var mySite = manager.Sites.Add(siteName, "http", binding, sitePath);
mySite.ApplicationDefaults.ApplicationPoolName = siteName;
mySite.TraceFailedRequestsLogging.Enabled = true;
mySite.TraceFailedRequestsLogging.Directory = sitePath + "\\faildir";

manager.CommitChanges();

When I breakpoint and look at the manager, the amount of Sites and Application Pools goes up each time - I'm at 8 sites already accroding to it. But, when a run inetmgr there is only the default web site and it's pool there! What gives?

enter image description here

I'm developing on a Windows 7 laptop, deploy will be to a Server 2008 machine.


Solution

  • It would seem that I was referencing the wrong Microsoft.Web.Administraiton DLL. And thus I was targeting an IIS I didn't even know I had installed. Nice.

    The correct one was at c:\windows\system32\inetsrv\. Props to https://stackoverflow.com/a/8481270/694325