惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
WordPress大学
WordPress大学
爱范儿
爱范儿
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
Recent Announcements
Recent Announcements
Latest news
Latest news
Last Week in AI
Last Week in AI
V2EX - 技术
V2EX - 技术
I
InfoQ
N
News | PayPal Newsroom
SecWiki News
SecWiki News
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
H
Hacker News: Front Page
S
SegmentFault 最新的问题
TaoSecurity Blog
TaoSecurity Blog
V
Visual Studio Blog
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园_首页
S
Security @ Cisco Blogs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
小众软件
小众软件
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tor Project blog
L
LINUX DO - 热门话题
月光博客
月光博客
S
Schneier on Security
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
Forbes - Security
Forbes - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog
A
Arctic Wolf
Webroot Blog
Webroot Blog
博客园 - 叶小钗
F
Fortinet All Blogs
S
Securelist
AI
AI
B
Blog RSS Feed
Security Latest
Security Latest

博客园 - volnet(可以叫我大V)

OpenAI CLIP 关键点 - 连接图像和文字 【笔记】跟吴恩达和IsaFulford学提示词工程(初级开发者入门课程) MacOS使用Charles抓去HTTPS数据 在浏览器的JavaScript里new Date().toUTCString()后,传递给C# DateTime().TryParse()会发生什么? 如何安装Docker UCP Git凭证存储(简单易懂,一学就会,认真看) - volnet(可以叫我大V) - 博客园 重启Ubuntu后Hadoop的namenode起不来的解决办法‬ Git撤销提交 MVC模式下如何实现RegisterStartupScript等功能 RESTful接口设计原则/最佳实践(学习笔记) 如何编译MongoDB? 《硅谷之谜》读书笔记 Google的Bigtable学习笔记(不保证正确性) 软件开发到底是怎么一回事呢? 如何控制自己之2016个人目标管理 如何自适应网页的协议(http/https/……) 数据库时间戳设计 AngularJS-Controller的使用-读书笔记 FIM相关报错汇总
ASP.NET 上传文件最大值调整
volnet(可以叫我大V) · 2016-06-15 · via 博客园 - volnet(可以叫我大V)

首先,最容易找到的是web.config下面配置:

    <!--maxRequestLength=50MB-->
    <httpRuntime targetFramework="4.5.2" maxRequestLength="51200"/>

这么设置会将请求的尺寸从默认4MB(4096KB)提升到50MB(51200KB)。

但是,如果只是这么设置的话,你会发现你的最大上传尺寸会停止在28.6MB,更大的文件上传,将返回404.13,表示内容长度过大。

原因在于IIS的默认设置,限定了maxAllowedContentLength的值。

<element name="requestLimits"><attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" />

该值在IIS_Schema.xml中设置。(将影响整个计算机)

IISExpress:IISExpress运行路径下,C:\Program Files (x86)\IIS Express\config\schema\IIS_schema.xml
IIS7、8:C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml

如果修改了这个值没有生效,两种可能,一种是当前运行的IISExpress/IIS没有关闭/重启。一种是web.config中有额外的配置(如下文所述)。

然而为了避免总是去修改全局的值,影响到同一台服务器上的其他web站点,我们还可以在web.config中进行配置。

  <system.webServer>
    <!--
      IISExpress:C:\Users\UserName\Documents\IISExpress\config\applicationHost.config
      IIS7、8:C:\Windows\System32\inetsrv\config\applicationHost.config
      <section name="requestFiltering" overrideModeDefault="Allow" />
      overrideModeDefault值设置成Allow的时候,本配置节才会生效。
      
      也可以在IIS_Schema.xml中设置。(将影响整个计算机)
      IISExpress:IISExpress运行路径下,C:\Program Files (x86)\IIS Express\config\schema\IIS_schema.xml
      IIS7、8:C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml
      修改defaultValue="30000000"(28.6MB)为需要的值。
      <element name="requestLimits"><attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" />
    -->
    <security>
      <requestFiltering>
        <!--maxAllowedContentLength=100MB-->
        <requestLimits maxAllowedContentLength="104857600"></requestLimits>
      </requestFiltering>
    </security>

为了使该内容生效,需要配置“允许继承”,在applicationHost.config中搜索<section name="requestFiltering" overrideModeDefault="Allow" />中的关键字,确保这个值为Allow即可。

IISExpress:C:\Users\UserName\Documents\IISExpress\config\applicationHost.config
IIS7、8:C:\Windows\System32\inetsrv\config\applicationHost.config

参考资料:

http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

http://www.cnblogs.com/henryhappier/archive/2010/09/20/1832098.html

https://msdn.microsoft.com/en-us/library/ms689462(v=vs.90).aspx