When using the IClientMessageInspector
interface, can I cancel a request from the BeforeSendRequest
method? Returning null
sends the request anyway.
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
if(Condition)
{
return null; //I want cancel my send
}
else
{
return request;
}
}
You can cancel the request with IClientChannel's Abort method. But your client's dispatch method throws CommunicationObjectAbortedException.