I have the following test code. I always get the \"Task was cancelled\" error after looping 316934 or 361992 times.
If I am not wrong, there are two possible reasons why
I ran across this recently. As it turned out, when I started up the web application in debug mode, the start up URL was using https.
However, the URL for WebApi endpoint (in my config file) was using http. Once I update it to use https, I was able to call the WebApi endpoint.