MVC 4.5: Increase maximum Upload Size

XML
Copy to clipboard
fablecode
  1. <!--
  2. Source: http://stackoverflow.com/questions/23327338/maxrequestlength-for-net-4-5-1-framework
  3.  
  4. If you are hosted in IIS, you need two settings:
  5.  
  6. maxRequestLength - for ASP.net (measured in KB)
  7. maxAllowedContentLength - for IIS (measured in Bytes)
  8. Sample config: (this is for 100MB upload limit)
  9.  
  10. -->
  11.  
  12. <configuration>  
  13.     <system.web>  
  14.         <httpRuntime maxRequestLength="102400" executionTimeout="3600" />  
  15.     </system.web>  
  16. </configuration>
  17. <system.webServer>  
  18.    <security>  
  19.       <requestFiltering>  
  20.          <requestLimits maxAllowedContentLength="104857600" />  
  21.       </requestFiltering>  
  22.    </security>  
  23.  </system.webServer>  
  24.  
  25.  
  26. <!--
  27.  
  28. The smaller of the two will take precedence. For IIS, the default is 4MB.
  29.  
  30. Error handling
  31.  
  32. Both throws different exceptions.
  33.  
  34. maxRequestLength - Whenever a file exceeds this setting, you'll get an Application_Error (standard ASP error)
  35. maxAllowedContentLength - Whenever a file exceeds this setting, you'll get IIS error.
  36. The IIS error is harder to debug, so it is advisable that you set the maxAllowedContentLength larger. maxRequestLength is easier to catch since its at application level.
  37.  
  38. -->

    Leave a comment

     
    Visual verification
     

    Related books

    More InfoXML Programming Success in a Day: Beginner?s Guide to Fast, Easy, and Efficient Learning of XML Programming
    XML Programming Success in a Day: Beginner?s Guide to Fast, Easy, and Efficient Learning of XML Programming
    More InfoBeginning XML
    Beginning XML
    More InfoXML in a Nutshell, Third Edition
    XML in a Nutshell, Third Edition
    More InfoXML Crash Course: Step by Step Guide to Mastering XML Programming
    XML Crash Course: Step by Step Guide to Mastering XML Programming
    More InfoMicrosoft Excel 2013 Programming by Example with VBA, XML, and ASP (Computer Science)
    Microsoft Excel 2013 Programming by Example with VBA, XML, and ASP (Computer Science)
    More InfoXML: Visual QuickStart Guide (2nd Edition)
    XML: Visual QuickStart Guide (2nd Edition)
    More InfoDefinitive XML Schema, 2nd Edition
    Definitive XML Schema, 2nd Edition
    More InfoLearning XML, Second Edition
    Learning XML, Second Edition