public static Site GetSite(this IWebsitesServiceManagement proxy, string subscriptionId, string website, string propertiesToInclude) { // Try to find webspace for site from cache Site site = Cache.GetSite(subscriptionId, website, propertiesToInclude); if (site != null) { try { return(proxy.GetSite(subscriptionId, site.WebSpace, site.Name, propertiesToInclude)); } catch { Cache.RemoveSite(subscriptionId, site); throw; } } // If site was not in cache, find out in which webspace it could be var webspaces = proxy.GetWebSpacesWithCache(subscriptionId); foreach (var webspace in webspaces) { var websites = proxy.GetSites(subscriptionId, webspace.Name, propertiesToInclude); var matchWebsite = websites.FirstOrDefault(w => w.Name.Equals(website, System.StringComparison.InvariantCultureIgnoreCase)); if (matchWebsite != null) { return(matchWebsite); } } return(null); }