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

  • SEARCH
  • Home
  • 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 8621189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:45:53+00:00 2026-06-12T06:45:53+00:00

I am trying to post a Json to our web service. My problem is

  • 0

I am trying to post a Json to our web service. My problem is that when my request.ContentLength exceeds 7kb. I will get a web exception 500 at request.GetResponse(). But if my request.ContentLength is below 7kb, my post is successfully sent.

Error Message:

 The remote server returned an error: (500) Internal Server Error.

Source code:

public static string JsonPost(string url, string method, string postData)
{
    Uri address = new Uri(url + method);
    HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
    request.Method = "POST";
    request.ContentType = "application/json";
    byte[] byteData = UTF8Encoding.UTF8.GetBytes(postData);
    request.ContentLength = byteData.Length;
    using (Stream postStream = request.GetRequestStream())
    {
        postStream.Write(byteData, 0, byteData.Length);
    }
    try
    {
        using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
        {
            StreamReader reader = new StreamReader(response.GetResponseStream());
            string JsonResponse = reader.ReadToEnd();
            return JsonResponse;
        }
    }
    catch (WebException ex)
    {
        string message = ((System.Net.HttpWebResponse)(ex.Response)).StatusDescription;
        if (message.Contains("busy"))
            return message;
        else
            throw new Exception(message);
    }
}

Web.config:

        <?xml version="1.0"?>

<configuration>
  <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>

  <system.web>
    <httpRuntime executionTimeout="180" maxRequestLength="1048576" useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
    minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true" />

    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

    <authentication mode="Forms">
      <forms loginUrl="~/Home/" cookieless="AutoDetect" timeout="2880" />
    </authentication>

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>

  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Exception Logs:

    (System.Net.HttpWebResponse)(ex.Response)   {System.Net.HttpWebResponse}    System.Net.HttpWebResponse
    base    {System.Net.HttpWebResponse}    System.Net.WebResponse {System.Net.HttpWebResponse}
        CharacterSet    "ISO-8859-1"    string
        ContentEncoding ""  string
        ContentLength   1047    long
        ContentType "text/html" string
        Cookies {System.Net.CookieCollection}   System.Net.CookieCollection
        Headers {
            Access-Control-Allow-Origin: *
            Content-Length: 1047
            Cache-Control: private
            Content-Type: text/html
            Date: Tue, 18 Sep 2012 22:33:36 GMT
            Set-Cookie: ASP.NET_SessionId=belurseo1i0ureppkspetw1a; path=/; HttpOnly
            Server: Microsoft-IIS/7.0
            X-AspNet-Version: 4.0.30319
            X-Powered-By: ASP.NET
        }   System.Net.WebHeaderCollection
        IsMutuallyAuthenticated false   bool
        LastModified    {9/19/2012 6:34:07 AM}  System.DateTime
        Method  "POST"  string
        ProtocolVersion {1.1}   System.Version
        ResponseUri {http://localhost/service.svc/Update}   System.Uri
        Server  "Microsoft-IIS/7.0" string
        StatusCode  InternalServerError System.Net.HttpStatusCode
        StatusDescription   "The server encountered an error processing the request. Please see the server logs for more details."  string
        SupportsHeaders true    bool
  • 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-12T06:45:54+00:00Added an answer on June 12, 2026 at 6:45 am

    Try this:

    %windir%\system32\inetsrv\appcmd set config -section:requestFiltering -requestLimits.maxAllowedContentLength:1000000
    

    or if you only want to set it for your app:

    %windir%\system32\inetsrv\appcmd set config "Default Web Site/<your app>" -section:requestFiltering -requestLimits.maxAllowedContentLength:1000000
    

    You can find more limit options here.

    Hope this helps

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

Sidebar

Related Questions

I'm trying to POST some json to a web service that accepts json. The
I am trying to POST JSON content to a web service. It works fine
I am trying to POST JSON to a WCF service. The json object contains
I am trying to get my datatable to take a POST JSON output from
im trying to POST (cross domain) some data to a jersey web service and
Trying to get JQuery to post JSON to a server: $.ajax({ url: /path/to/url, type:
I noticed when trying to post form data in JSON format, that the following
I'm trying to get some json from an action but I have a problem.
I am trying to POST JSON to a WCF service. The json object contains
I am trying to post some JSON to a rest service using Apache Httpclient.

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.