2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > asp.net mvc Post上传文件大小限制 (转载)

asp.net mvc Post上传文件大小限制 (转载)

时间:2019-06-16 16:04:10

相关推荐

asp.net mvc Post上传文件大小限制 (转载)

最近发现在项目中使用jQuery.form插件上传比较大的文件时,上传不了,于是改了下web.config的上传文件最大限制。

<configuration> <system.web> <httpRuntime maxRequestLength="102400" executionTimeout="200" enable="true" /></system.web> </configuration>

改完后还是不能上传,最后在stackoverflow找到了答案,原来还要配置服务端的最大文件限制。

譬如限制最大文件为100M

<configuration> <system.web> <httpRuntime maxRequestLength="102400" executionTimeout="200" enable="true" /></system.web> </configuration><system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="104857600" /> </requestFiltering> </security> </system.webServer>

you are hosted in IIS, you need two settings:

maxRequestLength- for (measured in KB)maxAllowedContentLength- for IIS (measured in Bytes)

Error handling

Both throws different exceptions.

maxRequestLength- Whenever a file exceeds this setting, you'll get an Application_Error (standard ASP error)maxAllowedContentLength- Whenever a file exceeds this setting, you'll get IIS error.

The IIS error is harder to debug, so it is advisable that you set themaxAllowedContentLengthlarger.maxRequestLengthis easier to catch since its at application level.

stackoverflow答案地址:/questions/23327338/maxrequestlength-for-net-4-5-1-framework

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。