How would I programmatically get the port 80 Web Application Default URL for the Farm?
1 Answer
var webService = SPFarm.Local.Services.OfType<SPWebService>().FirstOrDefault();
if (webService != null)
{
var webApp = webService.WebApplications.FirstOrDefault(wa => wa.GetResponseUri(SPUrlZone.Default).Port == 80);
if (webApp != null)
{
Uri webAppUri = new Uri(webApp.GetResponseUri(SPUrlZone.Default).AbsoluteUri);