最近发现在项目中使用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 ASP.net (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 the maxAllowedContentLength larger. maxRequestLength is easier to catch since its at application level.

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

asp.net mvc Post上传文件大小限制 (转载)的更多相关文章

  1. asp.net mvc Post上传文件大小限制

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

  2. ASP.NET MVC 文件上传和路径处理

    ASP.NET MVC 文件上传和路径处理总结 目录 文件的上传和路径处理必须解决下面列出的实际问题: 1.重复文件处理 2.单独文件上传 3.编辑器中文件上传 4.处理文章中的图片路径 5.处理上传 ...

  3. ASP.NET MVC文件上传【转】

    最近用到了文件上传功能,下面给出ASP.NET MVC文件上传的一个简单示例: 一.前端代码 @using (Html.BeginForm("UploadFile", " ...

  4. MVC图片上传、浏览、删除 ASP.NET MVC之文件上传【一】(八) ASP.NET MVC 图片上传到服务器

    MVC图片上传.浏览.删除   1.存储配置信息 在web.config中,添加配置信息节点 <appSettings> <add key="UploadPath" ...

  5. Asp.Net Mvc异步上传文件的方式

    今天试了下mvc自带的ajax,发现上传文件时后端action接收不到文件, Request.Files和HttpPostedFileBase都接收不到.....后来搜索了下才知道mvc自带的Ajax ...

  6. ASP.NET MVC图片上传前预览

    回老家过春节,大半个月,在家的日子里,吃好睡好,人也长了3.5Kg.没有电脑,没有网络,无需写代码,工作上相关的完全放下......开心与父母妻儿过个年,那样的生活令Insus.NET现在还在留恋.. ...

  7. sping mvc+uploadify 上传文件大小控制3部曲

    页面使用uploadify 上传控件,使用spring CommonsMultipartipartResolver , 反向代理nginx nginx 配置文件 client_max_body_siz ...

  8. ASP.NET MVC异步上传文件

    自己做的一个小dome.贴出来分享一下: 前端: <form id="formfile" method="post" enctype="mult ...

  9. asp.net MVC ajax上传文件

    普通上传 view: <body> <form id="form1" method="post" action="@Url.Acti ...

随机推荐

  1. 【计算机网络】详解HttpURLConnection

    请求响应流程 设置连接参数的方法 setAllowUserInteraction setDoInput setDoOutput setIfModifiedSince setUseCaches setD ...

  2. 18 Command Line Tools to Monitor Linux Performance

    By Ravi Saive Under: Linux Commands, Monitoring Tools On: December 26, 2013 http://www.tecmint.com/c ...

  3. [转]ASP.NET Web API系列教程(目录)

    本文转自:http://www.cnblogs.com/r01cn/archive/2012/11/11/2765432.html 注:微软随ASP.NET MVC 4一起还发布了一个框架,叫做ASP ...

  4. Java网络编程二--基于UDP的编程

    DatagramSocket对象为基于UDP协议的Socket 构造器提供可以选择性绑定到指定端口和ip 创建完对象后调用:receive(DatagramPacket p) send(Dategra ...

  5. hdu 1394 逆序数(线段树)

    http://acm.hust.edu.cn/vjudge/problem/15764 http://blog.csdn.net/libin56842/article/details/8531117 ...

  6. IO流之Properties类

    Properties类介绍 Properties 类表示了一个持久的属性集.Properties 可保存在流中或从流中加载.属性列表中每个键及其对应值都是一个字符串. 特点: 1.Hashtable的 ...

  7. 详解WebApp与Native App的区别

    一篇真的很棒关于html5的Web App与Native App的技术分析 ! 自Iphone和Android这两个牛逼的手机操作系统发布以来,在互联网界从此就多了一个新的名词-WebApp(意为基于 ...

  8. Apache Flume

    An Event is a unit of data that flows through a Flume agent. The Event flows from Source to Channel  ...

  9. eclipse spring boot项目部署

    选中项目------>右键----->Run As------>Manven bulid-->填写Name:XXX; Goals:clean package -Dmaven.t ...

  10. EPS 转 pdf 在线

    EPS 转 pdf 在线网站 https://convertio.co/zh/eps-pdf/