/// <summary> /// IIS添加网站绑定 /// </summary> /// <param name="siteid"></param> /// <param name="ip"></param> /// <param name="port"></param> /// <param name="domain"></param> public static void AddHostHeader(string domain, string port = "80", string type = "http")//增加主机头(站点编号.ip.端口.域名) { ServerManager sm = new ServerManager(); //后面改成用枚举 var bindings = sm.Sites.First(c => c.Id == (long)IISEnums.WebSitId).Bindings; //"*:80:test2.web.cn" string bindingInformation = string.Format("{0}:{1}:{2}", "", port, domain + XMLHelper.GetNodeText(XMLPath.IISWebUrl)); AddBingding(bindings, bindingInformation); bindings = sm.Sites.First(c => c.Id == (long)IISEnums.MobileSitId).Bindings; //"*:80:test2.mobile.cn" bindingInformation = string.Format("{0}:{1}:{2}", "", port, domain + XMLHelper.GetNodeText(XMLPath.IISMobileUrl)); AddBingding(bindings, bindingInformation); sm.CommitChanges(); }