Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 4.42 KB

File metadata and controls

51 lines (37 loc) · 4.42 KB
title CHttpModule::Dispose Method
description CHttpModule::Dispose Method releases all resources used by the current instance of the C H t t p Module class.
ms.date 10/07/2016
ms.assetid f5640e4c-5cf4-b7a5-8980-71b0c814b450

CHttpModule::Dispose Method

Releases all resources used by the current instance of the CHttpModule class.

Syntax

virtual VOID Dispose(  
   VOID  
);  

Parameters

This method takes no parameters.

Return Value

VOID.

Remarks

IIS automatically calls the Dispose method at the end of the request.

Note

Typically you create a class that is derived from CHttpModule by using the C++ new operator. Classes that were created with the new operator do not need to implement the Dispose method to perform any cleanup at the end of the request.

Example

The following example demonstrates how to create a simple "Hello World" HTTP module. The module defines an exported RegisterModule function that passes an instance of an IHttpModuleFactory interface to the IHttpModuleRegistrationInfo::SetRequestNotifications method and registers for the RQ_BEGIN_REQUEST notification. IIS uses the IHttpModuleFactory::GetHttpModule method to create an instance of a CHttpModule class and returns a success status. IIS also uses the IHttpModuleFactory::Terminate method to remove the factory from memory.

When an RQ_BEGIN_REQUEST notification occurs, IIS calls the module's CHttpModule::OnBeginRequest method to process the current request. OnBeginRequest clears the response buffer and modifies the MIME type for the response. The method then creates a data chunk that contains a "Hello World" string and returns the string to a Web client. Finally, the module returns RQ_NOTIFICATION_FINISH_REQUEST to notify IIS that all notifications are finished and then exits.

[!code-cppCHttpModuleHelloWorld#1]

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 [!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

CHttpModule Class