5
  • From the Visual Studio select Create a new project. Select ASP.NET Core 3.1
  • Publish and Host in IIS
  • Increase upload file size this code :
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<IISServerOptions>(options =>
    {
        options.MaxRequestBodySize = 314572800;
    });

    services.AddControllersWithViews();
}

and web config:

<security>
    <requestFiltering>
      <!-- This will handle requests up to 300MB -->
      <requestLimits maxAllowedContentLength="314572800" />
    </requestFiltering>
</security>

The above applies correctly but the default timeout is 2 min

How can I increase the timeout in ASP.NET Core 3.1 app hosted in IIS?

Note: my web.config

<aspNetCore processPath="dotnet" arguments=".\AspCoreTestFileUpload.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />

for requestTimeout : Doesn't apply to in-process hosting. For in-process hosting, the module waits for the app to process the request.

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1#attributes-of-the-aspnetcore-element

I have to use inprocess hostingModel

spottedmahn
  • 11,379
  • 7
  • 75
  • 144
sbr
  • 101
  • 1
  • 1
  • 10

2 Answers2

5

issue is solved:

in web config :

<security>
    <requestFiltering>
      <!-- This will handle requests up to 300MB -->
      <requestLimits maxAllowedContentLength="314572800" />
    </requestFiltering>
</security>

and in asp core 3.1 ConfigureServices : I did not understand the reason, but this piece of code solved the problem

services.Configure<FormOptions>(options =>
{
    options.ValueLengthLimit = int.MaxValue;
    options.MultipartBodyLengthLimit = long.MaxValue; // <-- ! long.MaxValue
    options.MultipartBoundaryLengthLimit = int.MaxValue;
    options.MultipartHeadersCountLimit = int.MaxValue;
    options.MultipartHeadersLengthLimit = int.MaxValue;
});
spottedmahn
  • 11,379
  • 7
  • 75
  • 144
sbr
  • 101
  • 1
  • 1
  • 10
  • 1
    If your issue is solved then I request you to mark the helpful suggestion as an answer. This will help other people who face the same issue. – Jalpa Panchal Jun 19 '20 at 09:41
2

increase request time-out via this IIS setting:

  1. open IIS manager, select your site
  2. select the advance setting from the action pane
  3. in the advance setting under limit section set connection time out value.

iis manager connection time-out screenshot

spottedmahn
  • 11,379
  • 7
  • 75
  • 144
Jalpa Panchal
  • 5,345
  • 1
  • 4
  • 17