hello I have a little problem
So am calling an Api, I made a service
public class HttpService(HttpClient httpClient, IConnectivity connectivity) {
public async Task<T?> GetAsync<T>(string url) {
if (connectivity.NetworkAccess != NetworkAccess.Internet) {
await Shell.Current.DisplayAlert("Error",
"No internet connectivity"
, "OK");
return default;
}
// Add User-Agent header
httpClient.DefaultRequestHeaders.Add
("User-Agent",
"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
var response =
await httpClient.GetAsync(url);
if (response.IsSuccessStatusCode) {
var jsonData = await response.Content.ReadAsStringAsync();
var data = await response.Content.ReadFromJsonAsync<T>();
return data;
} else {
await Shell.Current.DisplayAlert("Error",
"We could not connect to the server", "OK");
}
return default;
}
}
}
So the app runs fine in android,
but as you can see, the image doesn't render in Widows, and I get the error
Microsoft.Maui.Controls.StreamWrapper: Warning: Could not retrieve https://www.sciencedaily.com/images/scidaily-icon.png, status code Forbidden
This only happens on windows
Maui version: 8.0.9
Affected platforms: Windows
Expected behavior: Show the image
Actual behavior: No image
Testing system: Windows 11
Net 8