I have setup a WCf service in my project using this tutorial: http://msdn.microsoft.com/en-us/library/ff521581.aspx

However, I'm POSTing lots of byte[] data to the service tocreate a file. I basically have a canvas drawing, which I convert to byte[] using javascript and then POST it to the server to create a new file.

However, this approach is flawed. The server errors out if the the byte data is big. I followed the turorial and could not find a way to increase the limits. I did find ways to modify Web.Config file, but my WCF service does not has a web.config file.

Any help is greatly appreciated!

  • This may be better suited for Stack Overflow Jul 23, 2012 at 19:57
  • Since the tutorial for setting up a wcf service based on SharePoint SharePoint, I thought it was best to post here. I will play around a bit, and post my results here. Because the way MSDN has that tutorial, I'm pretty sure a lot of people will have problem setting up configurations for the wcf service.
    – harsimranb
    Jul 23, 2012 at 20:14
  • I know what you're saying, and the rules of these forums are kind of convoluted. However, this is more specifically about WCF and IIS than about SharePoint. Jul 23, 2012 at 20:24
  • You might find there is a web.config, you should check in the c:\inetpub\wwwroot\wss\virtualdirectories\<your web>\web.config
    – Ian
    Jul 23, 2012 at 20:50

3 Answers 3


I solved this by creating a Feature and then add this code in FeatureInstalled method.

public override void FeatureInstalled(SPFeatureReceiverProperties properties)
    SPWebService contentService = SPWebService.ContentService;
    SPWcfServiceSettings wcfServiceSettings = new SPWcfServiceSettings();

    wcfServiceSettings.ReaderQuotasMaxStringContentLength = Int32.MaxValue;
    wcfServiceSettings.ReaderQuotasMaxArrayLength = Int32.MaxValue;
    wcfServiceSettings.ReaderQuotasMaxBytesPerRead = Int32.MaxValue;
    wcfServiceSettings.MaxReceivedMessageSize = Int32.MaxValue;

    // Note: "runtime.svc" must be in lowercase
    contentService.WcfServiceSettings["runtime.svc"] = wcfServiceSettings;


You cannot use web.config to change the settings for the SharePoint WCF services because the Factory classes referenced in the *.svc file do the configuration 'automatically'.

But you can use the SPWcfServiceSettings class to modify the quotas. (Note: This changes the quotas for all WCF services in the Farm that use the factory classes).

Here is an example on how to use the class: http://www.elumenotion.com/Blog/Lists/Posts/Post.aspx?ID=121

  • I ended up implementing a Geneirc Handler, which did not impose any limits. Since I'm working on a client project, I really don't want my WCF service quotas to affect all WCF services on the farm. Thanks for pointing that out though!
    – harsimranb
    Jul 24, 2012 at 22:12
  • Where should I use SPWcfServiceSettings?
    – Codler
    Nov 14, 2012 at 12:38

I eneded up implementing a Generic Handler (.ashx), which did not impose any limits to the data I was POSTing.

If anyone is interested in ASHX handler in SharePoint, you can check out this article: http://www.lifeonplanetgroove.com/2010/10/15/adding-and-deploying-generic-handlers-ashx-to-a-sharepoint-2010-visual-studio-project/

I'm not sure why WCF didn't like my byte[], it was around 26KB.

Your Answer

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

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