IDispensedHttpModuleContextContainer::ReleaseContainer Method

IIS 7.0

Deletes the context container if it is dispensed.

virtual VOID ReleaseContainer(  
) = 0;  


This method takes no parameters.

The ReleaseContainer method is not thread safe for implementers that are dispensed.

The behavior of this method depends on the implementation. You should use the following information as a guideline, but it might not be correct in all scenarios:

  • Most implementers declare a private Boolean value named dispensed; the default value is false and the default behavior is that dispensed is never set to true. However, if the implementation has set dispensed to true, when ReleaseContainer is called, the IDispensedHttpModuleContextContainer pointer calls delete on itself. Otherwise, ReleaseContainer is an empty operation.

  • If delete is called, IDispensedHttpModuleContextContainer enumerates its internal array of IHttpStoredContext pointers and calls the IHttpStoredContext::CleanupStoredContext method on any pointers that were added previously by using the IHttpModuleContextContainer::SetModuleContext method. The context container then disposes of the array memory on the heap and sets that array to NULL.

The following example shows a custom class named MyContainer that implements the IDispensedHttpModuleContextContainer interface. It also shows a custom class named MyClass that implements a method named GetModuleContextContainer. MyClass manages a MyContainer pointer during the lifetime of a MyClass pointer.

// The MyContainer class implements the   
// IDispensedHttpModuleContextContainer interface.  
class MyContainer : public IDispensedHttpModuleContextContainer  
    // The MyContainer method is the public  
    // constructor for the MyContainer class.  
    // Make this method protected if the   
    // MyContainer class is abstract.  
    // dispensed: true if the container should  
    // call delete this when the ReleaseContainer  
    // method is called.  
    MyContainer(bool dispensed = false)   
        : m_dispensed(dispensed)  
    // The ReleaseContainer method   
    // calls delete this if this container  
    // is dispensed.  
    virtual VOID ReleaseContainer(VOID)  
        if (m_dispensed)  
            delete this;  
    // Implement additional   
    // IDispensedHttpModuleContextContainer  
    // pure virtual methods if this class  
    // is not abstract.  
    // The MyContainer method is the private  
    // destructor for the MyContainer class.  
    // Make this method protected and virtual   
    // if the MyContainer class expects   
    // to be a class of derivation. This method   
    // should not be public because   
    // IDispensedHttpModuleContextContainer pointers  
    // should be disposed externally only by   
    // calling the ReleaseContainer method.  
    // Specify a Boolean value for dispensing.  
    bool m_dispensed;  
// Create the MyClass class.  
class MyClass  
    // The MyClass method is the public  
    // constructor for the MyClass class.  
        m_container = new MyContainer;  
    // The MyClass method is the   
    // public virtual destructor   
    // for the MyClass class. This destructor  
    // calls ReleaseContainer on the internal  
    // IDispensedHttpModuleContextContainer  
    // pointer and sets that pointer to NULL.  
    virtual ~MyClass()  
        m_container = NULL;  
    // The GetModuleContextContainer method  
    // returns an IHttpModuleContextContainer  
    // pointer.  
    // return: a static upcast   
    // IDispensedHttpModuleContextContainer.  
    virtual IHttpModuleContextContainer*   
        return static_cast<IHttpModuleContextContainer*>  
    // Implement additional IHttpUrlInfo  
    // pure virtual methods if this class  
    // is not abstract.  
    // Specify a private  
    // IDispensedHttpModuleContextContainer  
    // pointer.  
    IDispensedHttpModuleContextContainer* m_container;  

Client- IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server- IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016 Technical Preview
Product- IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- IIS Express 7.5, IIS Express 8.0, IIS Express 10.0

IDispensedHttpModuleContextContainer Interface
IHttpApplication::GetModuleContextContainer Method
IHttpConnection::GetModuleContextContainer Method
IHttpContext::GetModuleContextContainer Method
IHttpFileInfo::GetModuleContextContainer Method
IHttpModuleContextContainer Interface
IHttpSite::GetModuleContextContainer Method
IHttpUrlInfo::GetModuleContextContainer Method
IMetadataInfo::GetModuleContextContainer Method