Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebView - assets are not loaded inside html #6165

Open
fairking opened this issue Apr 16, 2022 · 5 comments
Open

WebView - assets are not loaded inside html #6165

fairking opened this issue Apr 16, 2022 · 5 comments
Labels
area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area/single project ☝️ Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer control-webview p/2 Work that is important, but not critical for the release platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@fairking
Copy link

fairking commented Apr 16, 2022

Description

Maui Assets are not accessible via WebView.

The following html file:

<!DOCTYPE html>
<html>
<head>
    <title>MAUI WebView Sample</title>
    <meta charset=utf-8>
    <meta name=format-detection content="telephone=no">
    <meta name=msapplication-tap-highlight content=no>
    <meta name=viewport content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width">

    <script src="/assets/app.js"></script>
    <script type="module" crossorigin src="/assets/vendor.js"></script>
    <link rel="stylesheet" href="/assets/app.css">
</head>
<body>
    <p>An image should be here: <img href="/images/cat-icon.png" /></p>
    <p id="cssMessage">If the css loaded properly this text is blue.</p>
    <p id="jsMessage">js resources NOT loaded.</p>
    <p id="vendorMessage">vendor resources NOT loaded.</p>
</body>
</html>

not loading assets or images.

The way how it was loaded:

using (var sr = new StreamReader(FileSystem.OpenAppPackageFileAsync("spa/index.html").GetAwaiter().GetResult()))
{
    webView.Source = new HtmlWebViewSource()
    {
        Html = sr.ReadToEnd(),
        BaseUrl = "ms-appx-web:///spa/",
    };
}

Please see the sample project: https://gitlab.com/fairking/mauiwebviewsample
I am trying to make it work on Windows (I have not tested it on Android yet).
I was following those docs: https://docs.microsoft.com/en-us/dotnet/maui/user-interface/controls/webview#display-a-local-html-file

image

Steps to Reproduce

https://gitlab.com/fairking/mauiwebviewsample

Version with bug

Release Candidate 1 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows SDK 10.0.19041

Did you find any workaround?

no

Relevant log output

No response

@fairking fairking added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 16, 2022
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 18, 2022
@XamlTest
Copy link
Collaborator

Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32414.199.main]. Repro on Windows. Sample Project: 6165.zip

@Redth Redth added this to the 6.0.300 milestone Apr 20, 2022
@ghost ghost added the area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 20, 2022
@fairking
Copy link
Author

fairking commented Apr 23, 2022

Some additional info.

If I try to load an image with full url I got the following error message ERR_UNKNOWN_URL_SCHEME: ms-appx-web:///:

image

@davidortinau davidortinau added the p/1 Work that is critical for the release, but we could probably ship without label Apr 30, 2022
@Redth Redth added p/2 Work that is important, but not critical for the release and removed p/1 Work that is critical for the release, but we could probably ship without labels May 3, 2022
@samhouts samhouts added the area/single project ☝️ Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer label May 4, 2022
@samhouts
Copy link
Member

samhouts commented May 4, 2022

Still an issue on 6.0.300-rc.4.5681.

@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 5, 2023
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 20, 2023
@XamlTest
Copy link
Collaborator

Verified this on Visual Studio Enterprise 17.6.0 Preview 4.0. Repro on Windows 11 with below Project:
6165.zip

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area/single project ☝️ Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer control-webview p/2 Work that is important, but not critical for the release platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants