0

I did a test against a WCF server where the response from the server exceeds the MaxRecievedMessageSize property defined in the client-side binding object, resulting in a CommunicationException. I examined request and response using Fiddler. Despite exceeding the MaxRecievedMessageSize, the entirety of the response is sent to the client.

I believe I am missing the point of this behavior. As I see it, no bandwidth is saved as the data has already been received. The client application could have processed the data but the client binding has discarded before it is given to the application.

If saving bandwidth is not the purpose of the MaxReceivedMessageSize on the client-side, what is it for?

4

1 回答 1

1

答案很简单:安全。

如果您的客户端可以对服务器说:“哦,顺便说一下,不要费心向我发送大于 X 字节的回复”,那么带宽确实会更好,但这是他们没有实现的 :-)

即使是这样,如果服务器有错误,或者故意行为不端怎么办……如果服务器返回一个 2 TB 的字符串怎么办?然后,您的客户端将尝试分配 2TB 缓冲区来接收请求,并且可能会收到 OutOfMemoryException。那会让你的客户失望。

于 2014-01-30T10:22:23.157 回答