Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
BeforeSendReply Method
Collapse the table of content
Expand the table of content

IDispatchMessageInspector::BeforeSendReply Method

Called after the operation has returned but before the reply message is sent.

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

void BeforeSendReply(
	Message^% reply, 
	Object^ correlationState
)

Parameters

reply
Type: System.ServiceModel.Channels::Message%

The reply message. This value is null if the operation is one way.

correlationState
Type: System::Object

The correlation object returned from the AfterReceiveRequest method.

Use the BeforeSendReply method to perform custom behavior prior to sending the return message. The correlationState is the object returned from the AfterReceiveRequest method that you can use to perform correlation between inbound and outbound calls to support your behavior.

The following code example shows a basic IDispatchMessageInspector that writes a string to the console when it is invoked.

No code example is currently available or this language may not be supported.

The following code example shows the implementation of an IServiceBehavior that adds the Inspector IDispatchMessageInspector to the DispatchRuntime::MessageInspectors collection.

No code example is currently available or this language may not be supported.

The following code example shows the use of an application configuration file to load the service behavior that inserts the Inspector IDispatchMessageInspector.

No code example is currently available or this language may not be supported.
<configuration>
  <system.serviceModel>
    <services>
      <service 
        name="Microsoft.WCF.Documentation.SampleService"
        behaviorConfiguration="inspectorBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/SampleService" />
          </baseAddresses>
        </host>
        <endpoint
          address=""
          binding="wsHttpBinding"
          contract="Microsoft.WCF.Documentation.ISampleService"
        />

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="inspectorBehavior">
          <serviceInspectors />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <add 
          name="serviceInspectors" 
          type="Microsoft.WCF.Documentation.InspectorInserter, HostApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        />
      </behaviorExtensions>
    </extensions>
  </system.serviceModel>
</configuration>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft