zoukankan      html  css  js  c++  java
  • .net core部署到ubuntu 上传文件超过30MB

    默认的上传文件不能超过30MB,需要修改几个地方

    一、web.config中添加配置

    <requestLimits maxAllowedContentLength="2147483647" ></requestLimits>
    

    (1)如果是开发环境,通过IIS Express添加

    (2)如果是生产环境,添加到发布后的web.config中

    在标签<system.webServer>中加入<security>内容

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
          </handlers>
          <aspNetCore processPath=".hiRen.Tourism.UI" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" />
       <security>
          <requestFiltering >
            <requestLimits maxAllowedContentLength="2147483647" ></requestLimits>
          </requestFiltering>
        </security>
        </system.webServer>
      </location>
    </configuration>
    <!--ProjectGuid: 74eb1354-a638-4903-8784-2a74d874e010-->
    

      

    二、在startup的ConfigureServices方法中

                services.Configure<FormOptions>(options =>
                {
                    //设置上传文件大小限制
                    options.ValueLengthLimit = int.MaxValue;
                    options.MultipartBodyLengthLimit = int.MaxValue;
                });
    

      

    三、在保存文件的Controller的Action上加标签

            [RequestSizeLimit(1024_000_000)]
            //[DisableRequestSizeLimit]  //或者取消大小的限制
            [HttpPost]
            public async Task<IActionResult> Create(VideoMultipleLanguage ml, IFormCollection fc)
            {
            }
    

      

    四、修改Nginx的配置文件

    位置:/etc/nginx/nginx.conf

    在http{}中加入 

    client_max_body_size 1000m; 

    建议修改连接时间

    keepalive_timeout 1800;

  • 相关阅读:
    我要AFO啦好伤感啊
    noip2012~2015刷题小记录
    【20161114模拟赛】
    第5模块闯关CSS练习题
    HTML练习题
    Mysql常用命令行大全
    mysql破解密码安装与基本管理
    python 闯关之路四(下)(并发编程与数据库编程) 并发编程重点
    Python/ selectors模块及队列
    python3 中 Event.wait 多线程等待
  • 原文地址:https://www.cnblogs.com/fireicesion/p/11274813.html
Copyright © 2011-2022 走看看