1

How would I programmatically get the port 80 Web Application Default URL for the Farm?

1
  • In the concept of SharePoint there is no default web application on port 80. In most of my installations there are multiple web aplications using port 80 and non of them is using the server name. May 14, 2013 at 14:35

1 Answer 1

2
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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.