【发布时间】:2014-12-06 05:07:30
【问题描述】:
我正在开发一个允许用户上传文件的 MVC5 项目。我已经有了过滤无效文件扩展名的方法(只允许使用图片和 pdf)。但是,当我尝试上传大文件时,无论扩展名如何,都会出现此错误:
HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds
the request content length.
上传的方法甚至没有被调用,它直接进入错误页面。
我发现一个帖子表示我需要修改我的项目的web.config 文件,我这样做了:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="6000000" />
</requestFiltering>
</security>
我仍然收到错误,所以我也尝试将<httpRuntime maxRequestLength="6000" executionTimeout="3600" /> 添加到<system.web>,但这引发了这个错误:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data
for the page is invalid.
显然,这一行必须用于早期版本的 IIS。
我还找到了另一个解决方案,建议在我的服务器上编辑applicationHost.config 文件,如项目的web.config;这也没有用。
有什么建议吗?
【问题讨论】:
标签: c# asp.net-mvc-5 iis-8