Skip to content

Need AndroidHttpClientHandlerType Support in MAUI .NET Android #8470

@TonyLugg

Description

@TonyLugg

Android application type

.NET Android (net7.0-android, etc.)

Affected platform version

Android SDK 33

Description

One of my apps sends requests with custom headers to a customer API, and the requests are denied because of additional headers that are causing issues. I got around this issue with Xamarin Android by configuring HttpClient implementation as Default, which sets the csproj property, AndroidHttpClientHandlerType, to empty string. Doing this eliminated the additional headers Android seems to add. MAUI .NET Android must also use Android HttpClient implementation because the additional headers are added. My customer is unable to change their API middleware. I tried adding the AndroidHttpClientHandlerType property to the csproj file in MAUI but it had no effect.

Attached are two solutions, a working Xamarin Forms version and the non-working MAUI version.
HttpHeaderTestMaui.zip
HttpHeaderTestXF.zip

In the image below, the left is the working Xamarin headers, and the right is the non-working MAUI headers:

image

Steps to Reproduce

Running either of the two sample apps and pressing "GET TEST" will return from our test API the headers that were passed to the API.

Did you find any workaround?

Not yet.

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: HTTPIssues with sockets / HttpClient.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions