1

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

  • 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. – Marco Scheel May 14 '13 at 14:35
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, privacy policy and cookie policy

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