We are accessing default port number using ServerManager class from IIS in customer machines. But the Console didn’t run some of the machines and show Microsoft.Web.Administration.dll is required. Is this assembly is Redistributable? Or Is there any other way to get the default Port number? I am using below code to get the Port Number.
using (ServerManager serverManager = new ServerManager())
{
SiteCollection allsites = serverManager.Sites;
foreach (Site site in allsites)
{
if (site.Name == "Default Web Site")
{
BindingCollection allBindings = site.Bindings;
foreach (Binding bind in allBindings)
{
if (bind.Protocol == "http")
{
PortNo = bind.BindingInformation.ToString();
int portNoLenth = PortNo.Length; PortNo = PortNo.Substring(2, portNoLenth - 3); break;
}
}
}
}
}
Please help me to solve this issue.