当把Asp.net core 程序发布到IIS10运行时,可能会遇到上传附件的业务场景,有时根绝客户业务需求,附件的可能会很大。IIS 里有设置了一个安全机制,默认上传文件的大小为30M,当超过30M就需要手动配置它的大小。下面有两种方式:
1.1、打开 “管理” > “配置编辑器”
1.2、打开 “system.webServer/security/requestFiltering” 目录节点,并编辑 maxAllowedContentLength 属性的大小(字节)
2.1 、也可以在项目中web.config 配置文件中做更改,如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
</handlers>
</system.webServer>
</location>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="62914560" />
</requestFiltering>
</security>
</system.webServer>
</configuration>