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-->

  • 相关阅读:
    PLSQL Developer新建表空间
    oracle中where子句和having子句中的区别
    ORACLE基本数据类型
    Oracle数据库字符集问题
    问题及解决方法
    Show Profile
    批量数据脚本
    慢查询日志
    GROUP BY关键字优化
    order by关键字优化
  • 原文地址:https://www.cnblogs.com/lladmin/p/13379924.html
Copyright © 2011-2022 走看看