Max upload size for ASP.MVC CORE website

后端 未结 2 1136
栀梦
栀梦 2021-02-08 20:59

How can I set maximum upload size for an ASP.NET CORE application?

In the past I was able to set it in web.config file like this:



        
2条回答
  •  滥情空心
    2021-02-08 21:18

    You can configure the max limit for multipart uploads in the ConfigureServices method:

    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure(options =>
        {
            options.MultipartBodyLengthLimit = 52428800;
    
        });
    
        services.AddMvc();
    }
    

    You can also configure the MaxRequestBufferSize by using services.Configure, but it looks like this is going to be deprecated in the next release.

提交回复
热议问题