Connection Reset due to large file upload but conf

2019-08-02 09:28发布

I am having errors attempting to upload a file larger than 4 megs in my MVC project. The upload works fine for smaller files. Looking online, I saw that I should add

<httpRuntime maxRequestLength="200000" executionTimeout="240"/>

to my web config, in system web, but that has had no effect. The connection is still resetting. Are there other configs that need to be changed that I may have missed? The file is 10 megs, so that request length is plenty large enough.

The request is not timing out, the connection is reset instantly.

I also tried adding

<security >
  <requestFiltering>
    <requestLimits maxAllowedContentLength="1024000000" />
  </requestFiltering>
</security>`

to my webserver section in web config, but that had no effect either. The web config is the one located in the correct project, and the connection never reaches the breakpoint located in my controller, which makes me believe that this must be a config problem where an http request with a too-large file is being rejected. If that is the case, why doesn't the maxrequestlength attribute fix the problem?

2条回答
时光不老,我们不散
2楼-- · 2019-08-02 09:47

:/. Found the problem. I had been adding maxRequestLength to the wrong web config. There is one webconfig file in views, and one in the full project. I was putting it inside of views. Wasn't even aware of the fact that there were 2, and several people missed it as well. Terrible design to put two identically named and similarly purposed files inside of the project, seperated by only one layer of file depth.

查看更多
唯我独甜
3楼-- · 2019-08-02 10:09

just an update for IIS 7.x

you will need to add the following for newer versions of IIS:

<security>
    <requestFiltering>
          <requestLimits maxUrl="32767" maxQueryString="32767" 
            maxAllowedContentLength="2147483648"/>
    </requestFiltering>
</security>
查看更多
登录 后发表回答