For net.tcp, http, etc. absolutely not. (see comments above for some ideas, and may also be different for other protocols / bindings / etc.)
The reason is that server-side WCF infrastructure code will not use the channel until it completes the implementation of the service operation implementation code and sorts the response. Only then he will try to send a response and at that moment he will understand that the connection has already been interrupted by the client.
When the server receives this error, the user code (your implementation of the service operation) is already executed and therefore you can no longer respond to this. Perhaps this is possible from the dispatcher or another distribution point, but I personally have not tried it. However, this also will not save your server from unnecessary work, because, as said, disconnecting a client will still be recognized only when the server is really trying to send a response.
One โsimpleโ way to alleviate such problems may be to split the work performed into several service operations / calls (if at all possible, and not accidentally enter the server-side state in the process). Or, as others have said, ask the client to implement the โPingโ interface, which the server can use to check if the client remains โaliveโ and an answer is still needed.
source share