Share via


Dispose Method

The Dispose method of the SPWeb class releases all unmanaged resources used by the Web site object.

Remarks

Calling the Dispose method has the same effect as calling the Close method.

Use the Dispose method to close the SPWeb object and release resources when you are finished using the object. Do not reuse the object or objects obtained through the object after it is closed.

Warning  Do not use this method to close a shared resource, such as when the Web site object is provided by the GetContextWeb method in a Web Part. Instead let Windows SharePoint Services or your portal application manage the object. Using this method on a shared resource causes an access violation error to occur.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security