IGlobalTraceEventProvider::GetCurrentHttpRequestContext Method
Collapse the table of content
Expand the table of content

IGlobalTraceEventProvider::GetCurrentHttpRequestContext Method

IIS 7.0
 

Retrieves the HTTP context for trace events that are request specific.

virtual HRESULT GetCurrentHttpRequestContext(
   IHttpContext** ppHttpContext
) = 0;

ppHttpContext

A pointer to the address of an IHttpContext interface; otherwise, NULL.

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

Value

Definition

S_OK

Indicates that the operation was successful.

ERROR_NOT_SUPPORTED

Indicates that the method is not supported.

CGlobalModule derived classes that register for GL_TRACE_EVENT event types receive an IGlobalTraceEventProvider pointer as a parameter on the CGlobalModule::OnGlobalTraceEvent pure virtual method. You can then retrieve an IHttpContext pointer by calling the GetCurrentHttpRequestContext method on that IGlobalTraceEventProvider pointer.

One possible use for GetCurrentHttpRequestContext is to provide custom buffering of events.

GetCurrentHttpRequestContext behavior depends on implementation. You should use the following information as a guideline, but it may not be correct in all scenarios:

  • Classes that provide HTTP trace events declare a private IHttpContext pointer member variable. This variable is initialized during construction to a valid IHttpContext pointer. When you call GetCurrentHttpRequestContext, the dereferenced ppHttpContext parameter is set to this variable, and S_OK is returned.

  • Classes that provide global trace events do not modify the ppHttpContext parameter and return ERROR_NOT_SUPPORTED immediately.

IGlobalTraceEventProvider implementers are responsible for memory management with this data; therefore, IGlobalTraceEventProvider implementers that use dynamic memory allocation must release or call delete on the IHttpContext pointer when it is no longer needed.

IGlobalTraceEventProvider implementers are responsible for memory management with this data; therefore, IGlobalTraceEventProvider clients must not release or call delete on the returned IHttpContext pointer when this data is no longer needed.

Example

The following code example demonstrates how to create a global module that listens for GL_TRACE_EVENT events and declares and initializes an HTTP_TRACE_CONFIGURATION structure that filters for events. The module then retrieves the IHttpContext pointer by calling the GetCurrentHttpRequestContext method.

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:
© 2016 Microsoft