首页 > 解决方案 > How to Avoid "A task was cancelled" when debugging

问题描述

When debugging async services, in Visual Studio 2017, frequently the calling app somehow times out and returns "A Task was cancelled" error - when really I'm just taking too long debugging.

Is there any way to extend the timeout or suspend cancelling tasks when debugging?

I'm running a web app, async calling a separate rest service. Two visual studio solutions open, debugging from the web app solution steps straight into the other solution no problem - but the first solution raises the "Task Cancelled" error after about 5 minutes.

标签: c#visual-studiodebuggingasynchronous

解决方案


在您的 web.config 中,确保您具有以下字段:

<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" executionTimeout="1" />

小解释,executionTimeout 以秒为单位,只有在 debug=false 时才有效,如果编译中的调试为 true,则 executionTimeout 无用,变为最大值。检查以下答案以进行进一步解释。


推荐阅读