1. 修改IIS配置
ASP.NET 项目部署到IIS,如果上传文件过大,也需要在IIS中修改上传大小设置。配置方法有两种,一种是在IIS的配置编辑器中添加,另一种是直接修改项目中的web.config文件。具体配置方法如下:
-
打开 “管理” -> “配置编辑器”
-
选择节点“system.webServer/security/requestFiltering”,编辑“requestLimits ”项
-
修改 maxAllowedContentLength 的值,单位字节
2. 配置文件
修改的配置可以在项目中的web.config文件中查看,也可以直接修改配置文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\xxx.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
<system.webServer>
<security>
<requestFiltering>
<!--允许上传文件长度,单位字节(B),默认为30M,最大为2G -->
<requestLimits maxAllowedContentLength="300000000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
ASP.NET 项目部署到IIS,需要的环境变量要在IIS中配置,请看:Asp.Net 部署IIS10 设置环境变量