Replies: 1 comment
-
FWIW, below is a workaround for the BrowserWasm target. IMPORTANT does not work from VisualStudio. However, does work when served using Still no clue WRT Desktop. How it worksThis work around relies on the following:
Implementation
<ItemGroup>
<Folder Include="WebContent" />
<BundleResource Include="WebContent/**/*.*">
<Link>Platforms/iOS/Resources/WebContent/%(RecursiveDir)%(Filename)%(Extension)</Link>
</BundleResource>
<AndroidAsset Include="WebContent/**/*.*">
<Link>Platforms/Android/Assets/WebContent/%(RecursiveDir)%(Filename)%(Extension)</Link>
</AndroidAsset>
<Content Condition=" $(TargetFramework.Contains('windows')) OR $(TargetFramework.Contains('desktop')) OR $(TargetFramework.Contains('wasm')) "
Include="WebContent/**/*.*" />
</ItemGroup>
In BrowserWasm, this will create a folder, filled with all your web content, named
// In this sample, the variable _webView has already been assigned to our WebView2 instance.
var packageFolder = GetBootstrapBase();
var page = $"/{packageFolder}/WebContent/index.html";
_webView.CoreWebView2.Navigate(page); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does support for CoreWebView2.SetVirtualHostNameToFolderMapping exist for the Desktop and BrowserWasm targets? If so, can you provide a sample?
I'm trying the following:
MyProject/MyProject.csproj:
MyProject/MainPage.csproj:
Beta Was this translation helpful? Give feedback.
All reactions