SPSite.OpenWeb method
SharePoint 2013
Returns the Web site that is associated with the URL that is used in an SPSite constructor.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
The following code example returns the Web site that is located at http://Server_Name/sites/Site_Name/Subsite_Name.
string strUrl = "http://Server_Name/sites/Site_Name/Subsite_Name/default.aspx"; using (SPSite oSiteCollection = new SPSite(strUrl)) { using(SPWeb oWebsite = oSiteCollection.OpenWeb()) { ... } }
Note
|
|---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |
Note