c# - 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.
解决方案
在您的 web.config 中,确保您具有以下字段:
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" executionTimeout="1" />
小解释,executionTimeout 以秒为单位,只有在 debug=false 时才有效,如果编译中的调试为 true,则 executionTimeout 无用,变为最大值。检查以下答案以进行进一步解释。
推荐阅读
- ajax - 如何在回调中使用 ajax $.post()?
- excel - 在 VBA 中为 Excel 倒数计时器键入不匹配错误
- sql - SQL:在破折号字符之前获取子字符串。从“ABC-123”到“ABC”
- linux - 调用 main 两次行为不同
- multiprocessing - 如何使用 PyTorch 在 gpu 中运行特定代码?
- javascript - 如何在 react-native 中连接特殊符号,如 ¥
- c - mapPut 有什么问题?我找不到问题
- xss - 如何使用 HSTS(HTTP Strict Transport Security)拦截网站
- python - 使用 PyTorch 的 AlexNet 在训练后显示低准确率
- javascript - 验证输入字段 Fullname(Firstname,Lastname) - JavaScript