Home > Backend Development > C++ > How to Increase Maximum File Upload Size in ASP.NET Core?

How to Increase Maximum File Upload Size in ASP.NET Core?

Linda Hamilton
Release: 2025-01-29 01:11:10
Original
122 people have browsed it

How to Increase Maximum File Upload Size in ASP.NET Core?

How to increase the maximum file upload size in ASP.NET CORE?

Question:

In ASP.NET core MVC 6, how to upload the maximum file to unlimited? Solution:

ASP.NET CORE 2.0 and higher versions add additional file size limit through the Kestrel server, which is separated from IIS limit. To increase file upload size, you can use one of the following methods:

RequestSizelimit Properties:

For a specific MVC operation or controller, you can use

attributes to set the maximum request text size limit. For example, set the

method of the controller to 100,000,000 bytes:

IHTTPMAXREQUESTBODYSIZEFEATUR Intermediate Parts:

RequestSizeLimit MyController For the request that the unrepaired MVC operation, according to the basic configuration limit of each request, please use MyAction:

<code class="language-csharp">[HttpPost]
[RequestSizeLimit(100_000_000)]
public IActionResult MyAction([FromBody] MyViewModel data)
{
    //...
}</code>
Copy after login

Global configuration:

To change the maximum request the size of the maximum request, please modify the

attribute in the IHttpMaxRequestBodySizeFeature or

recovery in the
<code class="language-csharp">app.Run(async context =>
{
    context.Features.Get<IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = 100_000_000;
});</code>
Copy after login
method:

Set

Startup.Configure or in the HTTPSYS configuration in the Kestrel configuration to 0 to the request text size limit. UseKestrel

The above is the detailed content of How to Increase Maximum File Upload Size in ASP.NET Core?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template