Hello,
The performance difference you're seeing is likely due to changes in the underlying networking stack. .NET MAUI uses SocketsHttpHandler, which may negotiate HTTP/2 by default and applies different settings compared to Xamarin.Forms.
Recommendation
You could consider the following practices to improve your upload performance:
1. Choose the correct HTTP method
- Use
POSTfor creating new resources orPUTfor replacing existing ones - Avoid
GETrequests with request bodies, as this violates HTTP standards and can cause issues
2. Optimize your streaming approach
- Implement
StreamContentwith a 64KB buffer size for better performance - Use
ResponseHeadersReadto prevent buffering the entire response in memory
3. Test HTTP version differences
- Try forcing HTTP/1.1 for your upload requests to see if this improves performance
- HTTP/2's flow control can sometimes throttle long-running streams on certain servers
- Compare the results to help identify the best configuration for your scenario
4. Adjust timeout settings
- Set generous client timeouts (consider 15+ minutes for large files)
- Ensure your server timeout settings can accommodate the upload duration
5. Manage connections properly
- Limit concurrent uploads to avoid connection contention
- Reuse a single
HttpClientinstance per host to benefit from connection pooling - Consider setting
MaxConnectionsPerServer = 1to dedicate a connection during uploads
6. Fine-tune the handler (when needed)
- Disable
AutomaticDecompressionfor upload requests - Only use permissive certificate validation in test environments
7. Consider chunked uploads for large files
- Implement resumable uploads to improve user experience and handle network interruptions
I hope this helps you with your issue.