IIS Express的默认限制<limits>

web*_*orm 6 iis-7

我需要测试一个可以接受非常大文件的文件上传组件。我想在开发环境中进行本地测试,但是由于我使用IIS Express而不是IIS 7,所以我不确定在哪里进行全局更改。

在IIS 7中,无法通过web.config进行更改,而需要通过IIS管理器工具进行更改。有关示例,请参见此IIS文章

有谁知道如何使用IIS Express(在Visual Studio 2013中)进行相同的全局更改?

Sar*_*ley 6

如果建议的web.config更改ppascualv不起作用,请尝试将其放入IIS Express applicationhost.config中,该文件位于

%userprofile%\my documents\iisexpress\config\applicationhost.config
Run Code Online (Sandbox Code Playgroud)

<system.webServer>
Run Code Online (Sandbox Code Playgroud)

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="524288000"/>
    </requestFiltering>
</security>
Run Code Online (Sandbox Code Playgroud)

除非应用程序中的web.config覆盖它,否则应将其设置为全局。


Hei*_*erg 6

您基本上需要在web.config maxRequestLengthmaxAllowedContentLength上传文件中进行设置。

  • maxRequestLength 表示 ASP.NET 支持的最大文件上传大小
  • maxAllowedContentLength 这指定了 IIS 支持的请求中内容的最大长度

注意:maxRequestLength以千字节maxAllowedContentLength为单位,以字节为单位

默认情况下,Machine.config 被配置为接受最大 4096 KB (4 MB) 的 HTTP 请求,它反映在您的所有 ASP.NET 应用程序中。您可以直接更改 Machine.config 文件,也可以仅更改要更改的应用程序的 Web.config 文件

<system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="524288000"/>
            </requestFiltering>
        </security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>
Run Code Online (Sandbox Code Playgroud)

  • 您的回答提到了 maxRequestLength 和 maxAllowedContentLength 但您的示例显示了 2 个 maxAllowedContentLength 实例而没有 maxRequestLength 的示例 (2认同)