zoukankan      html  css  js  c++  java
  • .net core之上传文件的限制

    项目需求:需要能上传1G以上的大文件。

    .net core 对上传文件大小有默认限制,默认为40M

    Startup.cs

    public void ConfigureServices(IServiceCollection services)
    {
    services.AddMvc(config => config.Filters.Add<AuthFilter>())
    .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver())
    .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
    
    //解决文件上传Multipart body length limit 134217728 exceeded
    services.Configure<FormOptions>(x =>
    {
    x.ValueLengthLimit = int.MaxValue;
    x.MultipartBodyLengthLimit = int.MaxValue;
    x.MemoryBufferThreshold = int.MaxValue;
    });
    }

    发布之后 的web.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <system.webServer>
    <security>
    <requestFiltering>
    <!-- 2 GB -->
    <requestLimits maxAllowedContentLength="2147483648" />
    </requestFiltering>
    </security>
    <handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    </aspNetCore>
    </system.webServer>
    </configuration>
    <!--ProjectGuid: 325fd02e-815e-4a79-98eb-0cb84b11a404-->

  • 相关阅读:
    基站选址(编程之美2015资格赛)
    2月29日(编程之美2015资格赛)
    跳马
    电子老鼠闯迷宫
    解决按钮重复提交 unbind+bind+setTimeout
    XMLHttpRequest 中 blob类型数据转text
    ExtJs之列表(grid)
    ExtJs之组件(window)
    ExtJs基础
    问题与成长
  • 原文地址:https://www.cnblogs.com/lladmin/p/13379924.html
Copyright © 2011-2022 走看看