Condividi tramite


IClientMessageInspector.BeforeSendRequest Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Enables inspection or modification of a message before a request message is sent to a service.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Syntax

'Declaration
Function BeforeSendRequest ( _
    ByRef request As Message, _
    channel As IClientChannel _
) As Object
Object BeforeSendRequest(
    ref Message request,
    IClientChannel channel
)

Parameters

Return Value

Type: System.Object
The object that is returned as the correlationState argument of the AfterReceiveReply method. This is nulla null reference (Nothing in Visual Basic) if no correlation state is used.
The best practice is to make this a System.Guid to ensure that no two correlationState objects are the same.

Remarks

Implement the BeforeSendRequest to inspect or modify a request message before it is sent.

Examples

The following code example shows an implementation that writes strings to the console when the implementation is called.

The following code example shows how to use an System.ServiceModel.Description.IEndpointBehavior to insert the client message inspector in the client endpoint.

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.