SPWeb.Close Method

Closes the Web site at the end of a request and releases resources.

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

Syntax

Public Sub Close

Dim instance As SPWeb

instance.Close()
public void Close()

Remarks

Calling the Close method has the same effect as calling the Dispose method. Use the Close method to close the SPWeb object and release resources 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, you can use the Close 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 the Close method to close the object, but instead allow Windows SharePoint Services or your portal application to manage the object. For more information about good coding practices, see Best Practices: Using Disposable Windows SharePoint Services Objects.

See Also

Reference

SPWeb Class

SPWeb Members

Microsoft.SharePoint Namespace

Other Resources

Best Practices: Using Disposable Windows SharePoint Services Objects