Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8910089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:36:04+00:00 2026-06-15T03:36:04+00:00

I have a C# WebService setup to return JSON info for use on a

  • 0

I have a C# WebService setup to return JSON info for use on a mobile. Everything is working fine, except one of the calls which now throws an “HTTP Error 502 (Bad Gateway): The gateway or proxy server received an invalid response from an upstream server”.

The error started when I increased the data the call returned. The data is read from a JSON file residing on the server. The size of this data file was previously 1,324,859 bytes which worked fine (and still does), the new data file is 1,563,570 bytes and this is the one failing.

It seems pretty obvious that I hit some sort of default limit to how much I can return in a single call, but I cannot for the like of me figure out how to increase this limit. Googling points in the direction of setting maxJsonLength, but this doesn’t seem to have any effect.

Below is the drilled down code for the WebService and more importantly my web.config. I should say that the call is working fine locally, meaning while running in VS2010, but failing on the server (GearHost running IIS 7.5).

I am quite a novice in configuring/setting up IIS, so any help is greatly appreciated.

[ServiceContract]
public interface IMyService
{
  [OperationContract]
  [WebInvoke(Method = "GET", UriTemplate = "/GetItems", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  Item[] GetItems();
}

public class MyService : IMyService
{
  public Item[] GetItems()
  {
      var result = ReadDataFile<List<Item>>(DataType.Items);
      return result == null ? null : result.ToArray();
  }
}

I have tried so many settings by now, that I am not even sure what needs to be in here and what shouldn’t…

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="system.web.extensions"         type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <system.web>
    <customErrors mode="On"/>
    <compilation debug="true" targetFramework="4.0" />
    <caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="NoCacheProfile" noStore="true" duration="0" varyByParam="none" enabled="true"/>
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="StreamedRequestWebBinding"
                 bypassProxyOnLocal="true"
                 useDefaultWebProxy="false"
                 hostNameComparisonMode="WeakWildcard"
                 sendTimeout="10:15:00"
                 openTimeout="10:15:00"
                 receiveTimeout="10:15:00"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transferMode="StreamedRequest">
          <readerQuotas maxArrayLength="2147483647"
                        maxStringContentLength="2147483647" />
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service name="JSON_WebService.WoWService" behaviorConfiguration="ServiceBehaviour">
        <endpoint address ="" binding="webHttpBinding" bindingConfiguration="StreamedRequestWebBinding" contract="JSON_WebService.IWoWService" behaviorConfiguration="web">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="50000000"/>
      </webServices>
    </scripting>
  </system.web.extensions>
</configuration>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:36:05+00:00Added an answer on June 15, 2026 at 3:36 am

    After communicating back and forth with GearHost (the ones hosting the web service), they have confirmed that my problem is related to a server error and not a programming/web.config error.
    The jsonSerialization setting should have been sufficient.

    In their defense I must say that their support is really quite excellent and I think quite a few others would have dismissed my claim as being a development problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java WebService setup which consumes an xml file and want to
I have a webservice and ios application. I use ASIHTTPRequest.h, ASIFormDataRequest.h headers to handle
We have implemented webservice which generates xml response. I am facing issue while invoking
I have a WebService that when I use the instance of this webservice, occurs
I have a webservice which is accepting a POST method with XML. It is
I have an ASMX webservice setup on Microsoft Azure and I'm trying to send
I have a webservice that I am testing. When I use the personal asp.net
I have a web service method which i'd like to return multiple rows from
Following writing hessian serivce I have setup Hessian webservice in my spring application and
I'm fairly new to WebService developement and have just set up my own webservice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.