0

Is there any effective ways to prevent message size quota exceeded for NetTCP service that returns an undetermined-sized collection? Example I have the following service:

public List<string> GetDirInfo(string path)
{
    List<string> result;

    result = new List<string>(Directory.EnumerateDirectories(path));
    result.AddRange(new List<string>(Directory.EnumerateFiles(path)));

    return result;
}

which basically just returns a list of directories and files in that given path. At times, I will reached the message size quota, e.g. return C:\Windows\System32.

Without changing message size quota, what is the best way to handle or prevent this sort of service call? A few ways that I can think of:

  1. Convert to Stream service call
  2. Implement Pagination
  3. As a prevention, always check the size of result prior to returning.
  4. Implement Callback mechanism where service will return a series of fixed sized result back to the client.

Is there any WCF configuration where the returned message will be split into multiple packets and reconstruct back by CLR while confining to the message size quota.

Edit:

I saw several postings on similar subject matter, but it all involved in changing the message size. I do not want to change the default message size to minimized DOS attacks.

I want to get some advise on the best practices and how you guys are handling/implementing such a case where the returning result might exceed the message size quota.

SimonSays
  • 477
  • 5
  • 13

0 Answers0