Controller.Dispose Method
Releases all resources that are used by the current instance of the Controller class.
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
Overload List
Name | Description | |
---|---|---|
Dispose() | Releases all resources that are used by the current instance of the Controller class. |
|
Dispose(Boolean) | Releases unmanaged resources and optionally releases managed resources. |
See Also
Controller Class
System.Web.Mvc Namespace
Return to top
Controller.Dispose Method ()
Releases all resources that are used by the current instance of the Controller class.
Syntax
public void Dispose()
public:
virtual void Dispose() sealed
abstract Dispose : unit -> unit
override Dispose : unit -> unit
Public Sub Dispose
Implements
Remarks
The ASP.NET MVC framework calls Dispose when the request has completed processing. Developers typically do not have to call Dispose. The Dispose(Boolean) method overload is the preferred method to override. If you derive a class from Controller and the derived class uses unmanaged memory, managed operating-system resources (such as files), or COM objects, you should implement Dispose to clean up these resources. You should also call the Dispose method of the base class. The Dispose method leaves the Controller instance in an unusable state. After you call Dispose, you must release all references to the Controller instance so that the garbage collector can reclaim the memory that the Controller instance was occupying.
For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.
Return to top
Controller.Dispose Method (Boolean)
Releases unmanaged resources and optionally releases managed resources.
Syntax
protected virtual void Dispose(
bool disposing
)
protected:
virtual void Dispose(
bool disposing
)
abstract Dispose :
disposing:bool -> unit
override Dispose :
disposing:bool -> unit
Protected Overridable Sub Dispose (
disposing As Boolean
)
Parameters
disposing
Type: System.Booleantrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Remarks
The ASP.NET MVC framework calls Dispose when the request has completed processing. Developers typically do not have to call Dispose. If you derive a class from Controller and the derived class uses unmanaged memory, managed operating-system resources (such as files), or COM objects, you should implement Dispose to clean up these resources. You should also call the Dispose method of the base class. The Dispose method leaves the Controller instance in an unusable state. After you call Dispose, you must release all references to the Controller instance so that the garbage collector can reclaim the memory that the Controller instance was occupying.
For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.
Return to top