Share via

SPWebApplication Class

Represents an Internet Information Services (IIS) load-balanced Web application that is installed on the server farm.

Inheritance Hierarchy


Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No


<GuidAttribute("113FB569-7520-4651-8FC4-E9F4F5887618")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPWebApplication _
    Inherits SPPersistedUpgradableObject _
    Implements IBackupRestore, IMigratable
Dim instance As SPWebApplication
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPWebApplication : SPPersistedUpgradableObject, 
    IBackupRestore, IMigratable


All servers that run the parent Web service (SPWebService) of the Web application must have a provisioned instance of the application. All instances of the application must be configured identically.

Various objects in the Microsoft.SharePoint.Administration namespace provide a WebApplication property through which you can access the containing Web application. Use the WebApplication property of the SPSite class to get the Web application that contains a site collection. To get the Web application of the current HTTP context, you can use SPContext.Current.Site.WebApplication.

Use the WebApplications property of the SPWebService class to return an SPWebApplicationCollection object that represents the collection of Web applications within a Web service. Use an indexer to return a single Web application from the collection. For example, if the collection is assigned to a variable named myWebApplications, use myWebApplications[index] in C#, or myWebApplications(index) in Visual Basic, where index is either the name or the GUID that identifies the Web application.


The following example uses the Lookup method to change the maximum file size and per-user alert settings for a specified Web application.

Dim oWebApplication As SPWebApplication = SPWebApplication.Lookup(New Uri("http://MyServer:989"))

oWebApplication.MaximumFileSize = 100
oWebApplication.AlertsMaximum = 1000

SPWebApplication oWebApplication = SPWebApplication.Lookup(new Uri("http://MyServer:989"));

oWebApplication.MaximumFileSize = 100;
oWebApplication.AlertsMaximum = 1000;


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also


SPWebApplication Members

Microsoft.SharePoint.Administration Namespace