1

Can anyone explain to me why, more often than not (in production environment) <httpRuntime targetFramework="4.7" requestValidationMode="2.0" executionTimeout="120" /> is "ignored" by async marked requests?

here's a piece of code to serve as proof of concept:

public async Task<HttpResponseMessage> ImAlive()
    {
        int c = 0;
        do
        {
            await Task.Delay(1000);
            ILogger.Log("ImAlive!");
        } while (c<10000);
    }

Edit1: here's my system.web config section

<system.web>
<compilation targetFramework="4.7">
  <assemblies>
    <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="Telerik.ReportViewer.WebForms, Version=11.1.17.822, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" />
    <add assembly="Telerik.Reporting, Version=11.1.17.822, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" />
  </assemblies>
</compilation>
<httpRuntime targetFramework="4.7" requestValidationMode="2.0" executionTimeout="120" />
<authentication mode="Forms">
  <forms
     loginUrl="~/Account/LogOn" 
     timeout="720"
     path="/"
     requireSSL="false"
    />
</authentication>
<globalization culture="pt-BR" uiCulture="pt-BR" />
<membership defaultProvider="myCustomProvider">
  <providers>
    <clear />
    <add name="myCustomProvider" type="StudioTech.Service.Provider.CustomMembershipProvider, StudioTech.Service, Version=1.0.0.0, Culture=neutral" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
  </providers>
</membership>
<profile>
  <providers>
    <clear />
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
  </providers>
</profile>
<roleManager enabled="true" defaultProvider="myCustomProvider">
  <providers>
    <clear />
    <add name="myCustomProvider" type="StudioTech.Service.Provider.CustomRoleProvider,Studiotech.Service" />
  </providers>
</roleManager>
<pages validateRequest="false">
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
    <add namespace="Kendo.Mvc.UI" />
  </namespaces>
</pages>
<sessionState mode="Custom" customProvider="MySessionStateStore" timeout="120">
  <providers>
    <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="my host.com" port="6380" connectionTimeoutInMilliseconds="5000" operationTimeoutInMilliseconds="10000" retryTimeoutInMilliseconds="50000" ssl="false" />
  </providers>
</sessionState>
<httpHandlers>
  <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
  <add type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=11.1.17.822, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" path="Telerik.ReportViewer.axd" verb="*" validate="true" />
</httpHandlers>
<customErrors mode="Off" />
<httpModules>
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>

Leonardo
  • 10,737
  • 10
  • 62
  • 155

1 Answers1

0

The executionTimeout determines how long a request should wait before it completes. The whole idea behind executing an async task is to allow the request to complete before the async thread finishes executing (for the record, its NOT the only advantage, sometimes they are used to run tasks in parallel, share processing load in multi core cpus, etc..).

The new async thread can be alive for as long as you need, if you want it to stop after a certain amount of time, you should handle that using a timer or something else, executionTimeout refers to the main syncronous thread, not the new async because of what's mentioned above (that's the main reason behind creating a new async thread).

canolucas
  • 1,482
  • 1
  • 15
  • 32