My code is :
var serverManager = new ServerManager();
var regex = new Regex("^(http|https)://");
var host = regex.Replace(url, "");
var instance = serverManager.Sites.First(
site => site.Bindings.First(
binding => binding.Host == host
)
);
You can see I try to do a second select on the attribute of the first one because Bindings is a collection and I need a particular item of this collection. I get this error :
Cannot implicitly convert type 'Microsoft.Web.Administration.Binding' to 'Bool'.
Any idea to resolve that?
You’re looking for
site.Bindings.First(binding => binding.Host == host)returns aBinding, but it inside ofserverManager.Sites.First(...), which in turn expects a predicate (returning abool), not aBinding.The snippet above uses
Anyto get the first site which has a binding withHost == host.