How to Validate Existing IISWebsite Bindings and Port number

Posted by Nmdjack under C# on 3/16/2015 | Points: 10 | Views : 1013 | Status : [Member] | Replies : 0
Hi,
I have written following code for validate the exiting website binding information. But, I could not get the result. Its validate the sites from IIS express only. what can I do for validate the IIS Website programmatically.
my code is

bool bind=true;
using (ServerManager manager = new ServerManager())
{
SiteCollection sites = manager.Sites;
foreach (var IISsite in sites)
{
BindingCollection bindings = IISsite.Bindings;
foreach (Microsoft.Web.Administration.Binding binding in bindings)
{
var oo = IISsite.Bindings
.Where(b => b.EndPoint != null
&& b.EndPoint.Address.ToString() == Bindings
&& b.EndPoint.Port == portNumber)
.FirstOrDefault();
if (oo != null)
return false;
}
}
}
return bind;





Responses

(No response found.)

Login to post response