使用 IClientMessageInspector
时接口(interface),我可以取消来自BeforeSendRequest
的请求吗?方法?返回 null
无论如何发送请求。
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
if(Condition)
{
return null; //I want cancel my send
}
else
{
return request;
}
}
最佳答案
您可以使用 IClientChannel 的 Abort 方法取消请求。但是您客户的调度方法抛出 CommunicationObjectAbortedException .
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
if(Condition)
{
channel.Abort();
return null;
}
else
{
return request;
}
}
关于.net - 如何在 BeforeSendRequest 中取消请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16696750/