MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: With CoreWebView2.SetVirtualHostNameToFolderMapping shows error Ip adress when start a local site
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
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 :
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WPF initialization handler and the call to SetVirtualHostNameToFolderMapping, then reproduce the navigation to http://ThreeJS/index.html using the supplied index.html and runtime versions. Compare the initial IP address error with the later successful load and determine the cause; done means the behavior is explained and a verified fix or workaround is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100