Skip to content

Latest commit

 

History

History
96 lines (67 loc) · 7.69 KB

File metadata and controls

96 lines (67 loc) · 7.69 KB
title IHttpModuleContextContainer Interface
description The IHttpModuleContextContainer Interface maintains a collection of IHttpStoredContext pointers.
ms.date 10/07/2016
ms.assetid 9e80529b-fc32-c845-5d31-6feac3d7034b

IHttpModuleContextContainer Interface

Maintains a collection of IHttpStoredContext pointers.

Syntax

class IHttpModuleContextContainer  

Methods

The following table lists the methods exposed by the IHttpModuleContextContainer class.

Name Description
GetModuleContext Returns the stored context from the context container.
SetModuleContext Sets the stored context on the context container.

Derived Classes

Name Description
IDispensedHttpModuleContextContainer Extends IHttpModuleContextContainer by providing functionality for releasing a container.

Remarks

Many [!INCLUDEiisver] classes maintain a private IDispensedHttpModuleContextContainer pointer as a member variable. These classes implement various interfaces, including IHttpApplication, IHttpConnection, IHttpContext, IHttpFileInfo, IHttpSite, IHttpUrlInfo, and IMetadataInfo.

Each of these interfaces defines a GetModuleContextContainer method, which accepts no arguments and returns an IHttpModuleContextContainer pointer. When the various GetModuleContextContainer methods are called, most of these implementers return the private data as an upcast IHttpModuleContextContainer. This allows the interface implementers to expose custom containers while maintaining the lifetime of those containers.

You can define custom classes that implement the IHttpStoredContext interface and then create a pointer to this IHttpStoredContext class implementer by calling the new operator. You can then add and retrieve this pointer on an IHttpModuleContextContainer pointer by calling the SetModuleContext and GetModuleContext methods, respectively.

When the IHttpStoredContext pointer is no longer needed, the IHttpStoredContext::CleanupStoredContext method is called internally, where the implementer of the IHttpStoredContext interface method should usually call delete``this.

Caution

While it may be a safe operation to downcast an IHttpModuleContextContainer to an IDispensedHttpModuleContextContainer by using the dynamic_cast operator, you should avoid performing this cast. The IDispensedHttpModuleContextContainer interface adds only one method, ReleaseContainer, to its base interface, and this method should be called only internally.

Notes for Callers

In some cases, an IHttpModuleContextContainer pointer may be downcast to an IDispensedHttpModuleContextContainer interface to access extended behavior.

Caution

Before performing any downcast operation, always verify that the cast is correct to guarantee correct program behavior.

Note

Consider using the dynamic_cast operator whenever possible when you perform a downcast operation.

Example

The following code example demonstrates how to create a global module that listens for GL_TRACE_EVENT events and then writes custom IHttpStoredContext information to the Event Viewer.

Caution

[!INCLUDEiisver] generates a large number of events in the Event Viewer. To avoid a log overflow error in a production environment, you should generally avoid writing cache information to the event log. For demonstration purposes, this code example writes an entry to the Event Viewer in debug mode only.

[!code-cppIHttpModuleContextContainer#1]

The above code writes a new event to the Event Viewer, where the Data box contains consecutive strings similar to the following.

CStoredContext::Destructor  
CStoredContext::CleanupStoredContext  
CStoredContext::Display  
CStoredContext::Constructor  

Your module must export the RegisterModule function. You can export this function by creating a module definition (.def) file for your project, or you can compile the module by using the /EXPORT:RegisterModule switch. For more information, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.

You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.

Inheritance Hierarchy

IHttpModuleContextContainer

IDispensedHttpModuleContextContainer

Requirements

Type Description
Client - IIS 7.0 on [!INCLUDEwinvista]
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on [!INCLUDEwinsrv2008]
- 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
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100]
Header Httpserv.h

See Also

Web Server Core Interfaces