IHttpFileInfo::GetModuleContextContainer Method

IIS 7.0
 

Returns an IHttpModuleContextContainer pointer for the corresponding file.

virtual IHttpModuleContextContainer* GetModuleContextContainer(
   VOID
) = 0;

This method takes no parameters.

A pointer to an IHttpModuleContextContainer interface.

The GetModuleContextContainer method return value depends on implementation. By default, the current implementation creates an IDispensedHttpModuleContextContainer that is synchronized but not dispensed.

IHttpFileInfo implementers are responsible for memory management with this data; therefore, IHttpFileInfo implementers should create an IDispensedHttpModuleContextContainer pointer at construction and hold a private reference to this IDispensedHttpModuleContextContainer pointer for the life of the IHttpFileInfo pointer. When the GetModuleContextContainer method is called, you should upcast and return this same IDispensedHttpModuleContextContainer pointer. When the destructor of the class that implements the IHttpFileInfo interface is called, this destructor should call the IDispensedHttpModuleContextContainer::ReleaseContainer method on this private reference and then set that reference to NULL.

GetModuleContextContainer should not return NULL. If the internal container is NULL, set this internal container to the value on the call to IHttpServer::DispenseContainer, and then return this same container.

System_CAPS_noteNote

   Although implicit upcast operations are considered safe, consider using an explicit cast for program clarity. Also consider using the dynamic_cast operator whenever possible.

IHttpFileInfo implementers are responsible for memory management with this data; therefore, IHttpFileInfo clients must not release, call delete on, or attempt to downcast and call IDispensedHttpModuleContextContainer::ReleaseContainer on the returned IHttpModuleContextContainer pointer when this data is no longer needed.

Example

The following code example demonstrates a custom class named MyContainer that implements the IDispensedHttpModuleContextContainer interface, and a custom class named MyClass that implements the IHttpFileInfo interface. MyClass manages a MyContainer pointer during the lifetime of a MyClass pointer.

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.

Requirements

Type

Description

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

Header

Httpserv.h

Show: