Skip to content

Java.Net.MalformedURLException: unknown protocol #7353

@IvanDmitriev1

Description

@IvanDmitriev1

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

VS 2022 17.4.0 Preview 1.0, dotnet 6.0.400

Description

After switching to dotnet maui from xamarin.forms exception occurred Java.Net.MalformedURLException: 'unknown protocol: steammobile. I do not know where the steammobile protocol is, but in xamarin.forms and wpf dotnet 6 are fine.

As far as I understand, HttpClient on android uses HttpURLConnection, and there doesn't seem to be a Java.Net.MalformedURLException with it.

Steps to Reproduce

var url1 = "https://steamcommunity.com";
var url2 = "/mobileconf/conf?";

var client = new HttpClient();
client.BaseAddress = new Uri(url1);

try
{
	using var responseMessage = await client.GetAsync(url1 + url2);
}
catch (Java.Net.MalformedURLException e)
{
            
}

Did you find any workaround?

var url1 = "https://steamcommunity.com";
var url2 = "/mobileconf/conf?";

await Task.Run(() =>
{
	Java.Net.URL javaUrl = new Java.Net.URL(url1 + url2);
	var connection = (HttpURLConnection) javaUrl.OpenConnection()!;

	connection.SetRequestProperty("GET", null);
	var code = connection.ResponseCode;
});

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: HTTPIssues with sockets / HttpClient.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions