Share via


SPContext.Current property

Gets the context of the current HTTP request in Microsoft SharePoint Foundation.

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

Syntax

public static SPContext Current { get; }

Property value

Type: Microsoft.SharePoint.SPContext
The SharePoint Foundation context.

Remarks

The Current property provides properties that access various objects within the current SharePoint Foundation context, for example, the current list, Web site, site collection, or Web application.

Examples

The following example uses the Current property to access the collection of site collections in the current Web applicaton.

SPWebApplication oWebApplicationCurrent = SPContext.Current.Site.WebApplication;
SPSiteCollection collSites = oWebApplicationCurrent.Sites;

foreach (SPSite oSite in collSites)
{
   Response.Write(oSite.Url + "<BR>");
   oSite.Dispose();
}

See also

Reference

SPContext class

SPContext members

Microsoft.SharePoint namespace