Default Limits for IIS Express

前端 未结 4 661
再見小時候
再見小時候 2020-12-16 16:57

I need to test a file upload component that will be accepting very large files. I want to test locally in my development environment but since I use IIS Express instead of I

相关标签:
4条回答
  • 2020-12-16 17:28

    If the web.config change ppascualv suggested doesn't work, try putting it in the IIS Express applicationhost.config, which can be found at

    %userprofile%\my documents\iisexpress\config\applicationhost.config
    

    under

    <system.webServer>
    

    put

    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="524288000"/>
        </requestFiltering>
    </security>
    

    This should set it as a global, unless a web.config from an application overrides it.

    0 讨论(0)
  • 2020-12-16 17:38

    You basically need to set both in web.config maxRequestLength and maxAllowedContentLength to upload files.

    • maxRequestLength Indicates the maximum file upload size supported by ASP.NET
    • maxAllowedContentLength This specifies the maximum length of content in a request supported by IIS.

    Note:maxRequestLength is in kilobytes & maxAllowedContentLength is in Bytes

    By default, Machine.config is configured to accept HTTP Requests upto 4096 KB (4 MB) and it is reflected in all your ASP.NET applications. You can change the Machine.config file directly, or you can change only the Web.config file of the application(s) you want to

    <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="524288000"/>
                </requestFiltering>
            </security>
    </system.webServer>
    

     <system.webServer>
       <security>
          <requestFiltering>
             <requestLimits maxAllowedContentLength="1073741824" />
          </requestFiltering>
       </security>
     </system.webServer>
    
    0 讨论(0)
  • 2020-12-16 17:38

    You can use this in web.config

    <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="524288000"/>
                </requestFiltering>
            </security>
    </system.webServer>
    
    0 讨论(0)
  • 2020-12-16 17:45

    Working to get around the "400 Bad Request" due to request headers that are too big, against the Visual Studio 2019's default IIS Express instance, I couldn't get Sarah's solution to work, but found that the http.sys settings here did the trick.

    Specifically, I created inside HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters a DWORD registry value called MaxRequestBytes and setting it to a large enough value. For me, 33000 was enough. Also created MaxFieldLength in the same place, and set it to 33000. A machine reboot is mandatory for the setting to become effective.

    As for the cause of my problem, it's described here. It's essentially caused by authentication cookies that get placed inside the request headers. Pushing to an Azure App Service works just fine (the limit for the headers there is probably 32KB), but against the local IIS Express, it failed continuously, until the fix described above.

    0 讨论(0)
提交回复
热议问题