dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

.NET MAUI BLAZOR v.8 unable connect to the api with the http url #25901

Closed Shad0wSeeker closed 3 days ago

Shad0wSeeker commented 5 days ago

Description I'm trying to connect to my api in maui blazor, however, when running on Windows Machine it's written: Hmmm… can't reach this page It looks like the webpage at https://0.0.0.0/ might be having issues, or it may have moved permanently to a new web address.

When running on Android 14.0: There is no content at

I register my services like this:

builder.Services.AddHttpClient<CommonService>(client =>
{
    client.BaseAddress = new Uri("http://rentagym.runasp.net/");
});

and in the service I prescribe:

public async Task<IEnumerable<HallListRequestDTO>> GetHallListAsync(HallListFilter filter)
{
    return await _httpClient.GetFromJsonAsync<IEnumerable<HallListRequestDTO>>("swagger/api/common/hall/list");
}

Steps to Reproduce simple launch

Link to public reproduction project repository https://github.com/[Shad0wSeeker/GYmobile](https://github.com/Shad0wSeeker/GYmobile)

Version with bug net 8.0

Affected platforms Android, Windows Machine

Affected platform versions Android 13.0, 14.0

jfversluis commented 4 days ago

I'm not sure I entirely understand what you are trying to do here.

So ultimately, you're trying to reach the URL http://rentagym.runasp.net/swagger/api/common/hall/list?

Because if that's the case, I cannot reach this from a regular browser here on my machine as well, so it just doesn't seem to exist. If you remove the swagger part, so http://rentagym.runasp.net/api/common/hall/list that does seem to work.

Does that resolve your issue?

Additionally, I do strongly recommend to get HTTPS enabled on your server!

Shad0wSeeker commented 4 days ago

I have already changed the url to http://rentagym.runasp.net/api/common/hall/list and this did't solve the problem. Unfortunately, I can't change http to https because I can't do it on a free hosting(

danroth27 commented 3 days ago

I have already changed the url to http://rentagym.runasp.net/api/common/hall/list and this did't solve the problem. Unfortunately, I can't change http to https because I can't do it on a free hosting(

I believe Android will block clear text requests over HTTP by default unless you do some additional configuration: https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html