DafaDil
DafaDil

Reputation: 2553

How to Increase item size in Http Post

I am posting data into a IIS web server using C#.

I have used XML and the mode and I am getting an 'Bad Request Error' when posting very long data in one field. For example,

<Field1>TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT.......<Field1>

I have already modified my Web.Config

<webHttpEndpoint>
   <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836"  maxBufferPoolSize="21474836" ></standardEndpoint>
          </webHttpEndpoint>

What else do I need to do to make this work?

   <system.web>
        <authentication mode="Forms" />
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            </assemblies>
        </compilation>
        <httpRuntime maxRequestLength="204800" executionTimeout="12000" requestValidationMode="2.0" requestPathInvalidCharacters="" />
    </system.web>
    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
        <standardEndpoints>
            <webHttpEndpoint>
                <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836" maxBufferPoolSize="21474836"></standardEndpoint>
            </webHttpEndpoint>
        </standardEndpoints>
    </system.serviceModel>

Upvotes: 2

Views: 1136

Answers (2)

DafaDil
DafaDil

Reputation: 2553

I fixed it by adding the readerQuotas into the standardEndpoint

<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836"  maxBufferPoolSize="21474836" >
          <readerQuotas maxStringContentLength="2048000" maxArrayLength="2048000"  maxDepth ="65000"/>
        </standardEndpoint>
      </webHttpEndpoint>
        </standardEndpoints>

Upvotes: 0

Jasmine
Jasmine

Reputation: 4029

You need to fix this value in the web.config for all requests, not just for WCF services, as you have done...

<httpRuntime maxRequestLength="1234" executionTimeout="1200" />

You probably need to increase that number. This is for the HttpRuntime which happens first - all requests are subject to the rules defined by this tag. The request limit you set for WCF services will only be applied if the request passes this check (and others) first.

Upvotes: 1

Related Questions