Forum Xamarin.Android

How do I send User-Agent header in HttpRequestMessage?

I use this code to set the header.
request.Headers.Add("User-Agent", "MyApp");

Also tried to set default header on httpClient:
new HttpClient()
{
DefaultRequestHeaders =
{
UserAgent = { new ProductInfoHeaderValue("MyApp", "1") }
}
};

Both options work in Android and iOS emulators, also in on-device testing (Debug build), but not in Android Ad-Hoc build installed on device.
In the latter case User-Agent header is not send with the request.

What else should I configure to send User-Agent?
In case it's an Android bug, how can I work around it?

Tagged:
Sign In or Register to comment.