Pass web application object to the method and return site collection URL
private string GetSysGlobalSiteUrl(SPWebApplication webApplication)
{
string siteUrl = string.Empty;
string GLOBAL_SITE_TITLE = “some name”;
try
{
SPSiteCollection siteCollection = webApplication.Sites;
foreach (SPSite site in siteCollection)
{
SPWeb web = site.OpenWeb();
if (web.Title == GLOBAL_SITE_TITLE)
{
siteUrl = web.Url.ToString();
}
}
}
catch(Exception ex)
{
}
return siteUrl;
}
No comments:
Post a Comment