简体   繁体   中英

C# UWP displaying remote image loaded over HTTPS in Webview

I have a UWP app which has a local HTML file which has an IMG tag which loads a remote image over HTTPS. for example

<img src="https://www.tokntechnology.com/app/themes/tokn/src/JuiceBox/Blocks/HomeBanner/time-cap.png">

The HTML file is loaded correctly and display everything else except the images. The image (https) is never loaded no matter what with no error message anywhere. If I change image to a non-secure image (http), it loads in the webview with no fuss.

Is there something I'm missing? I would want to load images in the webview over HTTPS. Unlike previously asked questions, the image to be loaded is a remote image only available via HTTPS.

This is the same-referrer policy of the browser. In short, if your web page request is the same as the server address where the image is located, you can display the image, otherwise it will not work.

So, in order to be able to display the image correctly, you can modify the HTML so that the front end does not send referrer information.

<head>
    <meta charset="utf-8" />
    <title></title>
    <meta name="referrer" content="no-referrer" />
</head>

After adding this meta data, if the image does not perform other encryption operations, it will display normally.

Best regards.

This problem had no explanation of logic, so the solution was to create a new project and import all files from old into this new project.

After doing this everything started working fine with all images being displayed as expected. This is a solution for anyone else who might have weird behaviour in a C# project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM