HttpClient PostAsync gets cancelled when in Release

My application utilizes a few REST API endopints using HttpClient. My GetAsyncs are working perfectly fine both when used in Debug and Release mode. The problem occurs when I try to PostAsync a large picture to the API in Release mode. The PostAsync gets cancelled and a WebException is raised (with the message: "A task was cancelled"). I do not cancel the task anywhere in my code. Increasing the timeout doesn't work either - the error occurs approximately 20 seconds after PostAsync gets fired. In Debug mode the PostAsync works fine and uploads a picture in a few seconds when proper connection quality exists. To get it working in Release I need to check the Shared Runtime usage option in configuration. What might be the cause of such behavior? I don't want to use Shared Runtime in my application as I need to release it in Play Store.


  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    Hello @jkwi
    try to add perhpas permission to internet

    i'm not an expert but try it

  • jkwijkwi PLMember

    Internet permission is obviously added as I am utilizing other endpoints using GetAsync which I mention at the begining of my post.
    Thanks for the insight though.

  • Hi @jkwi ,
    Have you checked your project linker properties? Try to choose linking SDK assemblies only.

Sign In or Register to comment.