.NET MAUI Application show Images in Androind but not in Windows

Giuseppe Furlan 16 Reputation points
2022-12-21T10:32:08.123+00:00

I wrote a program with a main Login Page. Next to the User ID and Password ENTRY I want to make images appear.
When I run the program in Android, everything OK, the images show. If I run the program in Windows Machine the images are not seen.
How can I fix it?
Thank you

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,929 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,824 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,141 questions
{count} votes

2 answers

Sort by: Most helpful
  1. HappyCoder 0 Reputation points
    2023-04-25T12:38:47.43+00:00

    I had the same problem, fill in Height and Width

    <Image Source="solved.png"
       HorizontalOptions="Start"
       HeightRequest="100"
       WidthRequest="100"
       VerticalOptions="Center"
       Margin="8,0,0,0"
    />
    
    
    
    0 comments No comments

  2. osko 0 Reputation points
    2023-05-18T13:31:48.2466667+00:00

    Hi,

    I encountered a similar problem with .NET 7 MAUI.

    I tried to fetch an image using the "https://picsum.photos/id/1/100/100.jpg" URI, but it wasn't working on Windows.

    However, it ran without any problems on Android.

    What solved the issue for me was extending the DefaultRequestHeaders.

    var httpClient = new HttpClient();
                    httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537");
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.