find and solve || findandsolve.com
Please wait.....

Welcome back.






Before Read Terms of use

The request filtering module is configured to deny a request that exceeds the request content length in .NET Core

The request filtering module is configured to deny a request that exceeds the request content length in .NET Core


How to increase upload file size in ASP.NET Core or Increase upload file size in Asp.Net core (this iis solved like as given issue) in .NET Core

HTTP Error 413.1 - Request Entity Too Large

The request filtering module is configured to deny a request that exceeds the request content length.

Most likely causes:

Request filtering is configured on the Web server to deny the request because the content length exceeds the configured value.

Things you can try:

Verify the configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength setting in the applicationhost.config or web.config file.

More Information:

This is a security feature. Do not change this feature unless the scope of the change is fully understood. You can configure the IIS server to reject requests whose content length is greater than a specified value. If the request's content length is greater than the configured length, this error is returned. If the content length requires an increase, modify the configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength setting.

Answer


Option 1.

%windir%\system32\inetsrv\appcmd set config -section:requestFiltering -requestLimits.maxAllowedContentLength:1000000

 or if you only want to set it for your app:

%windir%\system32\inetsrv\appcmd set config "Default Web Site/<your app>" -section:requestFiltering -requestLimits.maxAllowedContentLength:1000000


Option 2.

Add your Startup.css in ConfigureServices metho like as

services.Configure<FormOptions>(x => x.ValueCountLimit = 1000000);


Option 3.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
      <requestLimits maxAllowedContentLength="737280000" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>


Option 4.

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

For IIS7 and above, you also need to add the lines below:

 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>    </security>
 </system.webServer>

Option  5.

[HttpPost]
[RequestSizeLimit(40000000)]
public async Task<IActionResult>FileUpload(IFormFile file)
{    //TODO: Save file your file
}

Option 6.

    [HttpPost]
    [DisableRequestSizeLimit,
    RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue,ValueLengthLimit = int.MaxValue)]
    public async Task<ActionResult> BulkAdd(string schema, IFormFile file)
    {
    }

Option 7.

[HttpPost]
[RequestFormLimits(MultipartBodyLengthLimit = 209715200)]
[RequestSizeLimit(209715200)]
public IActionResult Upload(IFormFile file)
{
}


Comments



Report Response