Web.config - 使用应用程序 requestLimits

San*_*530 1 web-config request limit

我有一个页面,用户可以在其中将文件上传到服务器。我指定了

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

在我的 Web.config 中,但我仍然收到请求太大的错误。我找到了一种解决方案 - 更改系统文件 applicationHost.config。我设置

<requestLimits maxAllowedContentLength="512000000">
Run Code Online (Sandbox Code Playgroud)

它解决了我的问题。但是我们不能在开发服务器上修改这个文件。我找到了一些解决方案,例如使用

<clear/>
Run Code Online (Sandbox Code Playgroud)

或者

<remove name="..."> 
Run Code Online (Sandbox Code Playgroud)

在我的 Web.config 中

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

但现在我明白了

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Run Code Online (Sandbox Code Playgroud)

Nei*_*son 6

我认为你需要设置

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="2097151" />
  </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

反而。那是 2GB - 我认为这是最大值。