Reason why JsonContent (From CoreFx) method TryComputeLength is False #43883
-
Hello, I'm having a hard time understanding why Scenario. If I run locally, I have no issue, I receive an answer from backend on which I make the request. But as soon as I deployed in Azure App Service, it returns me bad request. And I don't understand why The reason why I'm asking is because If I create a mockup The only solution that I found is to replace Also on the So anyone any idea, because I don't think is a bug in the JsonContent but in the same time I don't understand why it works locally but not on Azure App Service |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can use It also surprises me when I was debugging my code, because inspecting the json content in debugger will make the code execute successfully. Many code supposes chunked encoding is supported everywhere, because it's a part of HTTP spec. So does |
Beta Was this translation helpful? Give feedback.
TryComputeLength
means if the length can be given immediately. Serializing arbitrary content may consume time that's sensitive for control flow.You can use
LoadIntoBufferAsync()
to do the serialization. It will store the result internally, then the length can be get immediately. See my code here.It also surprises me when I was debugging my code, because inspecting the json content in debugger will make the code execute successfully.
Many code supposes chunked encoding is supported everywhere, because it's a part of HTTP spec. So does
HttpClient
.