Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When sending a request like shown below the Content-Type header appears to be set to application/x-www-form-urlencoded causing a ASP.Net internal server error: InvalidDataException: Form value count limit 1024 exceeded.
using (var msg = new HttpRequestMessage
Method = HttpMethod.Post,
RequestUri = new Uri("https://foo/bar"),
Content = new StreamContent(contentStream)
var handler = new AndroidClientHandler>();
handler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
var httpClient = new HttpClient(handler);
var httpResponse = await httpClient.SendAsync(msg);
Neither AndroidHttpClient nor StreamContent set the Content-Type header. The only class in System.Net.Http that sets this header to this value is FormUrlEncodedContent (https://msdn.microsoft.com/en-us/library/system.net.http.formurlencodedcontent(v=vs.118).aspx) but since your code excerpt doesn't mention it I don't think it is involved here. The only remaining option is that the header is added by the underlying Java HTTP client. Without a full working sample to reproduce the issue (if you can, please provide a small self-contained app that reproduces the problem) it's hard to tell what's going on.
You can try to set the Content-Type header yourself by using
var sc = new StreamContent (contentStream);
sc.Headers.ContentType = new MediaTypeHeaderValue ("text/plain");
and see if that works around the issue.