Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

SPContext.Current Property

Windows SharePoint Services 3

Gets the context of the current HTTP request in Windows SharePoint Services.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
public static SPContext Current { get; }

Property Value

Type: Microsoft.SharePoint.SPContext
A SPContext object that represents the Windows SharePoint Services context.

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

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();
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.