简体   繁体   中英

IIS Express and Visual Studio 2019 - 413.1 - Request Entity Too Large

I have a.Net Core 2.2 Service to which I am trying to submit a large-ish request payload (including several base-64 encoded files). Total size is just under 30mb. The controller immediately rejects with error 413.1 - Request Entity Too Large. I have done a bit of research on the issue, but most solutions focus on modifying uploadReadAheadSize in the full version of IIS (but this is IIS express, running locally in VS), or modifying the web.config file (this.Net Core project does not have one). The project is not going to be deployed in IIS, so I don't think the solutions I've found would work for me at that point either. How can I make this work locally for debugging purposes?

The default request body size limit is 28.6 MB for .NET Core >2.0

If you are not going to use IIS for your deployment and wanted to make it work for debugging purposes, you can use Kestrel and reset the maximum request body size restriction inside of your Program.cs as shown below

 public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .UseKestrel(options => { options.Limits.MaxRequestBodySize = null; });

You can know more about Kestrel's configuration options from here

Further, this change has been introduced as a breaking change in the version 2.0 of .NET Core. This announcement talks about the ways to perform this in MVC , Middleware and also globally like I showed above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM