0

I am calling a web request from my Delphi code to upload a file (size: 3 to 6 MB) but I am getting the error:

Maximum request length exceeded.

How do I fix this?

Update: I have updated the web.config file with the below code but I am still getting the same error. My server is IIS 8.5 on HostGator. I have also asked the HostGator team to increase my file size from server end.

<configuration>
  <system.web>
      <webServices>
          <protocols>
              <add name="HttpGet"/>
              <add name="HttpPost"/>
          </protocols>
      </webServices>
    <compilation debug="true" targetFramework="4.7.1" />
    <httpRuntime targetFramework="4.7.1" />
  </system.web>
<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="268435456" />
        </requestFiltering>
    </security>
</system.webServer>
</configuration>

I have tried using this:

<httpRuntime maxRequestLength="51200" />

but I got:

internal server error

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
S. B.
  • 186
  • 1
  • 12
  • What is the EXACT error message you get? Which line of your code EXACTLY trigger that error? btw: It is likely a server response which somehow limit the size of the file it accept. – fpiette May 18 '22 at 14:54
  • 4
    You are the **client** sending a request and the **server** enforces the maximum of the request size it accepts. There's nothing on the client side to "fix" - either someone configures the HTTP server to allow more, or you simply have to accept the limit. – AmigoJack May 18 '22 at 15:16
  • @AmigoJack, I have updated the web.config file with the required code but I am still getting the same error. Please check the edit in the question. – S. B. May 19 '22 at 10:03
  • Read the linked question's answers throughly: ["_Both of these values must match_"](https://stackoverflow.com/a/12496077/4299358), so a `maxRequestLength` of 51200 **KiB** must match a `maxAllowedContentLength` of 52428800 **bytes** (or 268435456 **bytes** must match 262144 **KiB**). Also learn where IIS stores its error details to look it up. – AmigoJack May 19 '22 at 11:13
  • Hi, even if both values are matching, if I add line: ; it still gives Internal server error. – S. B. May 19 '22 at 12:18
  • Learn how to work with IIS: [How to diagnose a 500 Internal Server Error on IIS 7.5 when nothing is written to the event log?](https://serverfault.com/q/407954) or [How to See Detailed 500 Errors?](https://serverfault.com/q/810347) or read the [official documentation](https://learn.microsoft.com/en-us/iis/configuration/). This is my last comment. – AmigoJack May 19 '22 at 17:11

0 Answers0