IIS 7.0 vs 7.5 Site Microsoft.Web.Administration.Site BindingCollection

I wrote a program that takes a list of host names and a site name and adds them as bindings to the site if they do not already exist on any site. The program is written in .NET 4.0 C #.

Locally (IIS 7.5, Win 7), the code below works fine. It detects snapping and exits. On my server (IIS 7.0, Win Server 2008), the check fails, and the binding is always added. What gives?

Is it wrong that the LINQ query is incorrect or that the Microsoft.Web.Administration library has some fundamental inadequate handling of IIS 7.0?

Here is the piece of code that should work on both machines:

ServerManager oIisMgr = new ServerManager();
Site oSite = oIisMgr.Sites[siteName];
string sBindInfo = ":80:" + this.StripUrl(hostName);

//See if this binding is already on some site
if (oIisMgr.Sites
    .Where(ST => ST.Bindings.Where(B => B.BindingInformation == sBindInfo).Any())
    .Any()) return true;

Binding oBinding = oSite.Bindings.CreateElement();
oBinding.Protocol = "http";
oBinding.BindingInformation = sBindInfo;
oSite.Bindings.Add(oBinding);

oIisMgr.CommitChanges();
+5
1

, . , IIS, "IP-:", , :

"*: 80: some.domain.com"

:

": 80: some.domain.com" //

, , , LINQ, .

+7

All Articles