Represents the method that will handle an asynchronous completion event, which occurs after an asynchronous operation has finished processing.
[IN] A pointer to an IHttpContext interface.
[IN] A DWORD value that contains the bitmask for the related notification.
[IN] true to indicate that the notification is for a post-event; otherwise, false.
[IN] A pointer to an IHttpEventProvider interface.
[IN] A pointer to an IHttpCompletionInfo interface.
Unlike many of the other CHttpModule methods that are called by registering for specific notifications, IIS will call a module's OnAsyncCompletion method only when an asynchronous operation has finished. For example, when a request-level module calls the IHttpResponse::WriteEntityChunks method and specifies asynchronous completion, IIS will call the module's OnAsyncCompletion method when the operation is complete.
When IIS calls the OnAsyncCompletion method, it will specify the notification type in the dwNotification parameter, and it will indicate whether the notification was for an event or post-event by using the fPostNotification parameter. IIS also provides an IHttpCompletionInfo interface that is pointed to by the pCompletionInfo parameter. You can use this interface to retrieve additional information about the asynchronous completion.
The following code example demonstrates how to create an HTTP module that performs the following tasks:
When a Web client requests a URL, IIS calls the module's OnBeginRequest method. This method performs the following tasks:
Clears the existing response buffer and sets the MIME type for the response.
Creates an example string and returns that to the Web client asynchronously.
Tests for an error or asynchronous completion. If asynchronous completion is pending, the module returns a pending notification status to the integrated request-processing pipeline.
IIS calls the module's OnMapRequestHandler method. This method performs the following tasks:
Flushes the current response buffer to the Web client.
Tests for an error or asynchronous completion. If asynchronous completion is pending, the module returns a pending notification status to the pipeline.
If asynchronous completion is required, IIS calls the module's OnAsyncCompletion method. This method performs the following tasks:
Tests for a valid IHttpCompletionInfo interface. If a valid IHttpCompletionInfo interface was passed, the method calls the GetCompletionBytes and GetCompletionStatus methods, respectively, to retrieve the completed bytes and return the status for the asynchronous operation.
Creates strings that contain the completion information and writes the information as an event to the application log of the Event Viewer.
The module removes the CHttpModule class from memory and then exits.