The remote server returned an unexpected response: (400) Bad Request.

The remote server returned an unexpected response: (400) Bad Request.

Old forum URL:

zaff posted on Wednesday, May 26, 2010


Apologies for asking this same question again. But I just cannot get a relatively small object to update through Wcf.

I am using Project Tracker Solution - PTWin Application and have changed NO code at all.

I log on as Admin and add a few roles, all works fine...... however once I get to just  10 roles and try to add another role and save I get the following error.

The remote server returned an unexpected response: (400) Bad Request.

I have tried adding the following line into the Web.Config



<httpRuntime maxRequestLength="2097151" />




straight after <system.web>

However I still get the error 

Any advice would be most appreciated.

Many Thanks


RockfordLhotka replied on Wednesday, May 26, 2010

There are several limits that need to be changed on the client and server.

JonnyBee replied on Wednesday, May 26, 2010

Or you could simply use the config variable CslaDataPortalUrl on the client:

    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
    <add key ="CslaDataPortalUrl" value ="http://localhost:21647/WcfPortal.svc"/>

  <!-- This part of config is no longer neccessary in CSLA4 Client Side when using default WCF values and specifying CslaDataPortalUrl. -->

Csla4 will auto configure to max length settings on client proxy when only CslaDataPortalUrl is specified.

Take a look at the SimpleNTier sample provided with Csla 4 and

zaff replied on Thursday, May 27, 2010


I'm using  csla version 3.5.3 at work but had a similar problem with version 4 beta at home.

Thanks for all your replies, Unfortunately I'm still not winning.


These are the changes I have made so far.


1. Added <httpRuntime maxRequestLength="2097151" /> into the <system.web> node in the Web.config for the following two applications PTWcfService AND WcfHost


2. In the PTWcfClient project in the app.config I have updated as highlighted



        <binding name="WSHttpBinding_IPTService" closeTimeout="00:01:00"

            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"

            maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"

            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"


          <readerQuotas maxDepth="1024" maxStringContentLength="2147483647" maxArrayLength="2147483647"

              maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />

          <reliableSession ordered="true" inactivityTimeout="00:10:00"

              enabled="false" />

          <security mode="Message">

            <transport clientCredentialType="Windows" proxyCredentialType="None"

                realm="" />

            <message clientCredentialType="UserName" negotiateServiceCredential="true"

                algorithmSuite="Default" establishSecurityContext="true" />




However I'm still getting the same error. Any more help would be appreciated



mbblum replied on Saturday, May 29, 2010

We hit the same issue, and a co-worker found it was the IIS setting, not WCF configuration. Within web.config's <system.web> look for:

      <httpRuntime maxRequestLength="400"
           executionTimeout="45"      />

The maxRequestLength is KB, so the above sample limits requests to 400KB. If the incoming request gets large than this, IIS will refuse it. The purpose is to limit attacks and DOS on your system, so keep as small as feasible for your system.

On the other side, the reason for our troubles is because as written it sends entire collections to save a single change. Instead it should only be sending the modified object. (Some entities do have collections that are to be saved as a group with a parent object, not individually. But only that parent should be Save and sent, not great-grand parents with other collections, possibly quite large.) I am in the process of changing this now to reduce the amount of overhead traffic on saves that simply wastes bandwidth and make the app appear slow to users.

Hope that helps, mbb

mbblum replied on Saturday, May 29, 2010

Oops, read the thread and not your original post close enough. You alread set that value.

Sorry about that.

mbblum replied on Saturday, May 29, 2010

Try this one more time. Verify the binding settings in the web.config match those in the app.config.

zaff replied on Tuesday, June 01, 2010


I do have the following line in my PTWcfService project (Is this what you mean??)




endpoint address="" binding="wsHttpBinding" contract="IPTService"/>


I'm guessing that as the application is actually working when small objects are passed that all the binding stuff will probably be OK.

It's just when the object gets a bit bigger, in this case the roles object which updates just fine upto 9 roles and it's adding a 10th role that causes the error so I think is it probably a setting somewhere that increases this default (small) size that can be passed around with WCF.

Copyright (c) Marimer LLC