[Problem/Bug]: With CoreWebView2.SetVirtualHostNameToFolderMapping shows error Ip adress when start a local site
What happened?
Hi, I use this configuration :
CoreWebView2.SetVirtualHostNameToFolderMapping(hostName, hostFolderPath, CoreWebView2HostResourceAccessKind.Allow);
//Where hostName = "ThreeJS", hostFolderPath="D:\WebView\ThreeJS"
to start a local site.
For starting the site , I use :
private void _WebView_CoreWebView2InitializationCompleted(object? sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
// Navigate to the index.html page
_WebView.Source = new Uri("http://ThreeJS/index.html");
}
Here is the index.html :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style>
body { margin: 0; }
</style>
</head>
<body>
<script type="module" src="/main.js"></script>
</body>
</html>
And when I run the code, I get :
Then after several seconds, I get the site :
Here is below a video :
https://github.com/MicrosoftEdge/WebView2Feedback/assets/86523070/004ee143-41d9-4e0a-aa58-38e19d4a2f01
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
124.0.2478.67
SDK Version
1.0.2478.35
Framework
WPF
Operating System
Windows 10
OS Version
Version : 22H2, Build : 19045.4291
Repro steps
Configure the WebView2 WPF for hosting in folder with :
CoreWebView2.SetVirtualHostNameToFolderMapping(hostName, hostFolderPath, CoreWebView2HostResourceAccessKind.Allow);
Where hostName = "ThreeJS", hostFolderPath="D:\WebView\ThreeJS"
private void _WebView_CoreWebView2InitializationCompleted(object? sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
// Navigate to the index.html page
_WebView.Source = new Uri("http://ThreeJS/index.html");
}
Here is the index.html (to put in D:\WebView\ThreeJS folder) :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style>
body { margin: 0; }
</style>
</head>
<body>
<!-- <script type="module" src="/main.js"></script> -->
</body>
</html>
Then you will see first the message about the Ip adresse.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
Hello, did you find something ?
➕ I have same issue
See issue 2381 and this comment: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2381#issuecomment-3032253958 It might help.
I am having the same issue. The only solution I found is to put a delay of 1 second between EnsureCoreWebView2Async and SetVirtualHostNameToFolderMapping