public WebSiteInfo GetWebsiteInfo(string webSiteID) { WebSiteInfo siteInfo = new WebSiteInfo(); DirectoryEntry rootEntry = GetDirectoryEntry(""); foreach (DirectoryEntry ent in rootEntry.Children) { if (ent.Name == webSiteID && ent.SchemaClassName == "IIsWebServer") { siteInfo.SiteName = ent.Properties[WebSiteParameter.ServerComment.ToString()].Value.ToString(); siteInfo.Bindings = ent.Properties[WebSiteParameter.ServerBindings.ToString()].Value; siteInfo.State = (WebSiteState)ent.Properties["ServerState"].Value; siteInfo.LogFileLocaltimeRollover = SmString.StringToBool(ent.Properties[WebSiteParameter.LogFileLocaltimeRollover.ToString()].Value.ToString()); siteInfo.LogFileDirectory = ent.Properties[WebSiteParameter.LogFileDirectory.ToString()].Value.ToString(); DirectoryEntry appInfo = ent.Children.Find("root", "IIsWebVirtualDir"); siteInfo.AccessUser = new IdentityAuthInfo(appInfo.Properties[WebVirtualDirParameter.AnonymousUserName.ToString()].Value.ToString(), appInfo.Properties[WebVirtualDirParameter.AnonymousUserPass.ToString()].Value.ToString()); siteInfo.AppPoolName = appInfo.Properties[WebVirtualDirParameter.AppPoolId.ToString()].Value.ToString(); siteInfo.DirectoryPath = appInfo.Properties[WebVirtualDirParameter.Path.ToString()].Value.ToString(); siteInfo.ScriptMaps = appInfo.Properties[WebVirtualDirParameter.ScriptMaps.ToString()].Value; return(siteInfo); } } DisposeDirectoryEntry(rootEntry); return(siteInfo); }
public static string GetWebRootUri() { string http = "http"; if (HttpContext.Current.Request.ServerVariables["HTTPS"] != null && SmString.StringToBool(HttpContext.Current.Request.ServerVariables["HTTPS"])) { http = "https"; } http = http + "://" + HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + HttpHelper.WebRoot; return(http); }