1

I limited my WCF service to allow requests up to 1 MB. This is done via binding configuration in web.config. This is working fine and client is getting 413 error code back in response. The only problem is the response body is empty. I want to include custom message in response body but I don't find a way to do it as .NET handles it automatically.

Let me know if anyone know how to add custom message in response of large requests.

  • consider adding more information to your question – Inder Jul 24 '18 at 17:07
  • Anyone who can't work out that a 413 response means their request was too large won't read the message anyway. – stuartd Jul 24 '18 at 17:31
  • See if [this](https://stackoverflow.com/questions/140104/how-can-i-return-a-custom-http-status-code-from-a-wcf-rest-method) one helps. – Griswald_911 Jul 24 '18 at 17:32
  • 1
    It helped but I am not sure where to write that code to throw the exception as in my case .NET/WCF throws the exception without hitting my method. The only thing I can specify in web.config is the size limit but not the handler to execute when received request is more than the specified size limit. – user10129272 Jul 24 '18 at 19:27
  • @user10129272: Does your service get instantiated at all? If the exception gets thrown from within your context's AppDomain, you should be able to capture the exception. It may help if you post some code, even if it doesn't appear to be getting called. – Griswald_911 Jul 26 '18 at 14:46
  • There is no code, its just WCF binding configuration you specify the max request size . – user10129272 Jul 26 '18 at 17:54

0 Answers0