/** <summary> /// 获取服务器IIS版本 /// </summary> /// <param name="DomainName"></param> /// <returns></returns> public WebServerTypes GetIISServerType(string DomainName) ...{ if ((SiteInfo.DomainName == null) || (SiteInfo.DomainName == "")) SiteInfo.DomainName = "LOCALHOST"; string path = "IIS://" + SiteInfo.DomainName + "/W3SVC/INFO"; DirectoryEntry entry = null; try ...{ entry = new DirectoryEntry(path); } catch ...{ return WebServerTypes.Unknown; } int num = 5; try ...{ num = (int)entry.Properties["MajorIISVersionNumber"].Value; } catch ...{ return WebServerTypes.IIS5; } switch (num) ...{ case 6: return WebServerTypes.IIS6; case 7: return WebServerTypes.IIS7; } return WebServerTypes.IIS6; }
使用C#设置IIS站点运行的.Net版本示例
最新推荐文章于 2022-11-18 15:46:46 发布