Say I have a WebView in my page, with its content loaded by WebView.NavigateToString(string html). Now the problem is the html string contains a few <img> tags like
<img src="http://www.remotefakesite.com/1.jpg" />
however the image can’t be downloaded correctly unless the request has a special cookie. But the request is sent by the control, I don’t know how to modify the request(adding a cookie to it). I’ve tried setting HttpRequest.DefaultWebProxy, but it doesn’t work for the requests sent by the built-in control.
An alternative solution is downloading the image by my own HttpWebRequest(with the correct cookie) to local folder and then modify the img tag in the html string to
<img src="files:///xxxxx" />
but obviously files:/// scheme is against the security policy of metro apps. Neither ms-appx nor ms-appdata works, because the downloaded images are not part of my project.
Do you have any solution?
If the image size isn’t a problem, you could try to download it using a custom HTTP request with the required cookies, base64 encode it, and insert it into the src attribute:
And pass it with the rest of the html to the WebView using the NavigateToString method.
This might not be the best solution in the world, but it just works, compared to other options.