I'm currently working on my first .NET MAUI app and I'm encountering an issue with accessing uploaded images that reside in a folder in the API and rendering them from within the app.
In general, when working on Visual Studio's Windows Machine emulator, I can use https://localhost:7267 for everything, but for the Android emulator, I have to switch to http://10.0.2.2:5157. Note the switch from https to http. The app works both ways, until:
I have a user avatar feature where a user can upload an image on registration. When I'm running the app on the Windows machine using https://localhost:7267, I can access the image within my app and render it on the dashboard page. It's stored in the API, which is run at localhost. The app attempts to access the image at https://localhost:7267/Images\b30965a2-9aa8-4e0e-bbbd-a0b93fa6490a_Joe.jpeg, for example.
However, when I switch to the Android version using http://10.0.2.2:5157, the app works in all other senses, but the image is not rendering in the app. It's trying to access an image at http://10.0.2.2:5157/Images\\b30965a2-9aa8-4e0e-bbbd-a0b93fa6490a_Joe.jpeg, for example, but the image is not found.
It seems like a problem many must have come up against. Any ideas?
For more context:
I can access the image via the first URL in a web browser (https://localhost:7267/Images\b30965a2-9aa8-4e0e-bbbd-a0b93fa6490a_Joe.jpeg). I can't do this with the second using the 10.0.2.2 IP address (http://10.0.2.2:5157/Images\\b30965a2-9aa8-4e0e-bbbd-a0b93fa6490a_Joe.jpeg), which makes sense. I CAN access it via a browser if I change the Android IP back to localhost (http://localhost:5157/Images//b30965a2-9aa8-4e0e-bbbd-a0b93fa6490a_Joe.jpeg). However, my Android app still won't see the image when trying with either of these URLs.