How can I have the list of all existing SharePoint Web Applications and their site collections from code behind .
foreach (SPWebApplication webApp in SPWebService.ContentService.WebApplications)
string webUrl = webApp.GetResponseUri(SPUrlZone.Default).AbsoluteUri;
SPSiteCollection sites = webApp.Sites;
Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).
SPWebApplicationCollection webAppColl = SPWebService.ContentService.WebApplications;
if (webAppColl != null)
foreach (SPWebApplication spWebApp in webAppColl)
SPSiteCollection sites = spWebApp.Sites;
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2 years ago