Asp.Net - 执行Async和Timeout

时间:2018-04-06 12:54:49

标签: c# asp.net async-await

任何人都可以向我解释为什么,通常情况下(在生产环境中)<httpRuntime targetFramework="4.7" requestValidationMode="2.0" executionTimeout="120" />被忽略&#34;通过async标记的请求?

这里有一段代码作为概念证明:

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

Edit1:这是我的system.web配置部分

<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>

0 个答案:

没有答案