我已经编写了一个程序,它接受主机名和网站名称列表,并将它们作为绑定添加到网站(如果它们不存在于任何网站上) 。该程序是用.NET 4.0 C#编写的。IIS 7.0 vs 7.5网站Microsoft.Web.Administration.Site BindingCollection
本地(IIS 7.5,Win 7),下面的代码工作正常。它检测绑定和退出。在我的服务器上(IIS 7.0,Win Server 2008),检查失败并且始终添加绑定。是什么赋予了?
这是LINQ查询错误还是它是Microsoft.Web.Administration库有一些基本的不足处理IIS 7.0?
下面是应在两台机器上工作的部分代码:
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();