0

I have a very confusing and frustrating issue. To cut a long story short I have a webAPI to convert a PDF into an image. I bind the source of an imageview to this with the help of a converter.

when I run the ASP.net project in debug mode and point the MAUI app to localhost it works fine. But when I try to deploy it, it's not working. I'm probably not explaining it very well. Please take a look at code below:

In XAML for MAUI app:

<Image Grid.Column="0" Source="{Binding PDFPath, Converter={StaticResource urlformatconverter}}" Grid.RowSpan="2" Aspect="Fill" MaximumWidthRequest="200" />

the converter looks like this:

 correctedstring = urlpath + pdfpath + pagesettings + xdim + sizeofimg + ydim + sizeofimg;

            return correctedstring;

path is now in UNC format as mapped drives were causing me even more of a headache.

The API takes a UNC path of the PDF and then returns the image. This works fine in a browser and the image is displayed to the correct size. It also works fine when the Asp app is running in debug on the localhost, but on the deployment server it won't work. I've checked permissions, and I can still view the image in the browser, but imageview is still blank.

Any ideas? I'm getting very frustrated!

Andrew Taylor
  • 145
  • 13
  • The only thing i can think of (and I am certainly not an expert) is that there is some sort of timeout? I don't get any errors. and the binding seems good since it works on localhost. – Andrew Taylor Sep 06 '22 at 11:25
  • are you sure your app is using the correct url? Have you checked connectivity to that url using the device browser? – Jason Sep 06 '22 at 13:01
  • You might be on to something. I tried on my windows PC, but not on the tablet. When I open the URL on android tablet, it warns me it's an unsafe connection. I believe this is because it's a self signed certificate..... so..... how to I get around that? Thanks again for your help! Better than banging my head against the wall :D – Andrew Taylor Sep 06 '22 at 13:17
  • https://www.google.com/search?q=xamarin+android+self+signed+certificate+site:stackoverflow.com – Jason Sep 06 '22 at 13:19
  • thanks, but i am trying to access https:// through XAML, not in code. So how can I allow self signed certificate – Andrew Taylor Sep 06 '22 at 13:59
  • you might not be able to do it in XAML – Jason Sep 06 '22 at 14:02
  • Hi, Ok, I got around this by just allowing http:// traffic rather than forcing https. It works on windows, but still won't work on android. I've checked in browser on android tablet and it works, but still won't load the image. Are there any permissions I need to enable for this? Pulling JSON string from http server works, but loading the image from http is failing on android... – Andrew Taylor Sep 07 '22 at 07:20
  • https://stackoverflow.com/questions/67538590/cleartext-http-traffic-to-not-permitted – Jason Sep 07 '22 at 09:50
  • thanks for that. I had cleartext set up. I discovered it was timing out when loading the images. So I've set a HeightRequest for the image and it seems to work *some* of the time, not all though.... still trying to pull massive images. Originally I found I was getting [Glide] Load failed for https://aka.ms/campus.jpg with size [1896x58], and a timeout. – Andrew Taylor Sep 07 '22 at 09:57
  • The image it is trying to load is actually 300x212 in size, i checked in chrome. (not the image in that link), but Glide is reporting it as 1896x58, i can't understand why – Andrew Taylor Sep 07 '22 at 10:50

0 Answers0