Sunday, August 18, 2019

Maximum request length exceeded in ASP.NET MVC

If you are using IIS for hosting your application, then the default upload file size if 4MB. To increase it, please use this below section in your web.config -
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>
For IIS7 and above, you also need to add the lines below:
 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>
Note:
  • maxRequestLength is measured in kilobytes
  • maxAllowedContentLength is measured in bytes
which is why the values differ in this config example. (Both are equivalent to 1 GB)

No comments:

Post a Comment

No String Argument Constructor/Factory Method to Deserialize From String Value

  In this short article, we will cover in-depth the   JsonMappingException: no String-argument constructor/factory method to deserialize fro...