SPWeb.Close Method

Closes the website at the end of a request and releases resources.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Sub Close
'Usage
Dim instance As SPWeb

instance.Close()
public void Close()

Remarks

Uses this method to release the resources of the SPWeb object when you are finished using the object. Do not reuse the object or objects that are obtained through the object after it is closed.

If you create an SPWeb object, use this method to close the object. However, if you have a reference to a shared resource, such as when the object is provided by the GetContextWeb method, do not use this method to close the object, but instead allow SharePoint Foundation or your portal application to manage the object. For more information about good coding practices, see Disposing Objects.

See Also

Reference

SPWeb Class

SPWeb Members

Microsoft.SharePoint Namespace

Other Resources

Disposing Objects