Forum General

How to set BaseUrl from WKWebview to reference local file like image, css, javascript file in html

KritsadaDechawantanaKritsadaDechawantana USMember
edited November 2018 in General


i can't use local image reference in html with WKWebview

Steps to Reproduce

  1. set up webview source in code behide
var source = new HtmlWebViewSource()
                Html = [email protected]"
    <title>Xamarin Forms</title>
    <p>This is an iOS web page.</p>
    <img src=""ob03.png"" />

source.BaseUrl = DependencyService.Get<IBaseUrl>().Get(); // this operation return path of directory contained image files "/var/mobile/Containers/Data/Application/BBD4FB76-852B-4BC8-BACF-A1DEAFE31C1F/Documents/mcontent/images/"
webview.Source = source;
  • webview don't display image but i change BaseUrl to bundle resouce webview display image normally

Expected Behavior

i need to display local images from local path like this "/var/mobile/Containers/Data/Application/BBD4FB76-852B-4BC8-BACF-A1DEAFE31C1F/Documents/mcontent/images/"

Sign In or Register to comment.