0

I have inherited a project that contains a set of wcf services that is hosted in iis with no config file entries. I need to increase the maxreceivedmessagesize wcf setting. How would I do this in code?

1
  • 1
    If you're on .NET 4.0 or later, you could also set a default binding in the config file with the larger size for maxReceivedMessageSize. Then you wouldn't need to do anything in the code (unless you want to).
    – Tim
    Apr 12, 2013 at 6:48

2 Answers 2

2

Try with this piece of code,

BasicHttpBinding binding = proxy.Endpoint.Binding as BasicHttpBinding;
binding.MaxReceivedMessageSize = 20000000;
0

For future reference, you can add this in your web.config (as @Tim suggested in the comments). Note that the basicHttpBinding doesn't have a name specified, so it becomes the default config for that binding type.

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding maxReceivedMessageSize="2147483647"/>
        </basicHttpBinding>
    </bindings>
</system.serviceModel>

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.