Partager via


SPWebApplication Class

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

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
        Microsoft.SharePoint.Administration.SPWebApplication
          Microsoft.SharePoint.Administration.SPAdministrationWebApplication

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

<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
[GuidAttribute("113FB569-7520-4651-8FC4-E9F4F5887618")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPWebApplication : SPPersistedUpgradableObject, 
    IBackupRestore, IMigratable

Remarks

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.

Examples

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

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

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

oWebApplication.Update();

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

Reference

SPWebApplication Members

Microsoft.SharePoint.Administration Namespace