【问题标题】:ASP.NET CORE settimeout in json fileASP.NET CORE 在 json 文件中设置超时
【发布时间】:2017-08-22 09:27:54
【问题描述】:

我从我的 asp.net 核心应用程序 [long requests] 和答案中收到 502.3 错误:Timeouts with long running ASP.NET MVC Core Controller HTTPPost MethodRequest timeout from ASP.NET Core app on IIS 我看到我需要延长超时时间,但每个答案都包含在 webconfig xml 文件中设置超时时间,并且我正在使用 json 文件进行配置。

    {
  "AppConfig": {
    "Name": "...",
    "ConnectionString": "Server=localhost;User Id=root;Password=....;Database=....",
  }

我也有一个launchSettings.json

    {
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:53573/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "SPS.Services": {
      "commandName": "Project"
    }
  }
}

xml 中的等价物应该是怎样的:

   <system.webServer>
     <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
        </handlers>
        <aspNetCore requestTimeout="00:20:00"  processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    </system.webServer>

我应该把它放在哪里?

我使用的是 AspNetCore 1.1.2

【问题讨论】:

    标签: asp.net json asp.net-core


    【解决方案1】:

    如果您在 IIS “后面”运行您的应用程序(根据 launchSettings,您这样做了),那么您必须确保链中的所有项目(IIS、调用 Kestrel 和 Kestrel 本身的 IIS/AspNetCore 模块)不会长时间运行请求。

    Kestrel 执行 not have any request timeouts,无需配置。

    对于配置 IIS 相关的东西,你仍然应该使用web.config,因为 IIS 对你的 json 文件一无所知。因此,请随时使用您提供的链接创建和修改 web.config 文件。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,解决它的唯一方法是为我的应用程序创建一个 web.config 文件。所以我现在有了 appsettings.json 和 web.config。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-10-24
        • 2020-04-10
        • 2017-10-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-02-18
        相关资源
        最近更新 更多