Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 5.63 KB

File metadata and controls

74 lines (51 loc) · 5.63 KB
title IHttpContext::ReleaseClonedContext Method
description Describes the IHttpContext::ReleaseClonedContext method and provides the method's syntax, return value, remarks, an example, and requirements.
ms.date 10/07/2016
ms.assetid f43a4f35-dc84-d61d-09e1-cd512ee0b14a

IHttpContext::ReleaseClonedContext Method

Releases a cloned IHttpContext instance.

Syntax

virtual HRESULT ReleaseClonedContext(  
   VOID  
) = 0;  

Parameters

This method takes no parameters.

Return Value

An HRESULT. Possible values include, but are not limited to, those in the following table.

Value Description
S_OK Indicates that the operation was successful.
ERROR_INVALID_PARAMETER Indicates that the parent context for the current request is not valid (for example, a child context is being released after the parent has been released).

Remarks

The ReleaseClonedContext method releases an instance of an IHttpContext interface. For example, if you create a child context by using the IHttpContext::CloneContext method, you would call the child's ReleaseClonedContext method to release the child context when you are finished using it.

Important

Calling the ReleaseClonedContext method to release a child request after releasing its parent context will return ERROR_INVALID_PARAMETER. For example, if you create a child context and then use that child to create a nested child request, you will need to release the child contexts in reverse-order of their creation.

Example

The following code example demonstrates how to create an HTTP module that performs the following tasks:

  1. The module registers for the RQ_MAP_PATH notification.

  2. The module creates a CHttpModule class that contains OnMapPath and OnAsyncCompletion methods.

  3. When a Web client requests a URL, IIS calls the module's OnMapPath method. This method performs the following tasks:

    1. Tests to see whether the URL for the current request has a trailing slash or ends with /default.aspx. If the URL ends with either element, the module uses the IHttpContext::CloneContext method to create a clone of the current request.

    2. Calls the clone's IHttpRequest::SetUrl method to set the URL for the clone to /example/default.aspx.

    3. Calls the IHttpContext::ExecuteRequest method to execute the child request.

    4. Tests for asynchronous completion. If asynchronous completion is pending, the module returns processing to the integrated request-processing pipeline. If not, the module releases the cloned context.

  4. If asynchronous completion is required, IIS calls the module's OnAsyncCompletion method. This method releases the cloned context.

  5. The module removes the CHttpModule class from memory and then exits.

[!code-cppIHttpContextExecuteRequest#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

IHttpContext Interface
IHttpContext::CloneContext Method
IHttpContext::ExecuteRequest Method