Contents - Index - Top


SetVirtualHostNameToFolderMapping

Interface AntView 

 

Type: Method

Parameters:  String hostName String folderPath TxHostResourceAccessKind accessKind

Returns: nothing

 

 

Map a virtual host Name to a folder Path in the current file system.

 

Use ClearVirtualHostNameToFolderMapping to remove the folder mapping.

 

Below is an example in DataFlex on how-to set the "rijksmuseum.localhost" domain hostname to a local folder on the file system that can look like "C:\Users\Public\Documents\DataFlex Demo\AppHtml\"

    

    Procedure OnComCreateWebviewCompleted Integer llHResult

      Boolean bIsCreated

      String sPath

      

      Get ComWebViewCreated to bIsCreated

      If (bIsCreated) Begin

        Get psAppHtmlPath of (phoWorkspace(ghoApplication)) to sPath

        Send ComSetVirtualHostNameToFolderMapping "rijksmuseum.localhost" sPath OLEhrakAllow

      End

    End_Procedure

 

or in Visual Basic:

    Private Sub MapLocalFolderToHostName()

      Dim Path As String

      Dim HostName As String

      

      Path = strGetVisualBasicDemoPath & "\html"

      HostName = "rijksmuseum.localhost"

      EdgeWebBrowser.SetVirtualHostNameToFolderMapping HostName, Path, hrakAllow

    End Sub

    

    Private Sub EdgeWebBrowser_OnCreateWebviewCompleted(ByVal HResult As Long)

      If EdgeWebBrowser.WebViewCreated = True Then

        MapLocalFolderToHostName

      End If

    End Sub

 

You are free to choose any domain name for the hostname. It does not have to represent an existing domain name, or even a hostname with an existing tld. You might want to avoid choosing an imaginary tld in order to avoid the issue mentioned below. 

The hostname should follow the basic format of a domain name, which can also include the host part, so it is in fact a FQDN.

 

 

A currently known issue with top level domains such as the .local TLD is that it can add an additional 2 second delay on resolving the first time.

See also:  MS Edge WebView2 github issue #2381.

In summary what is happening here is that WebView2 is treating the .local top level domain as a real domain and tries to resolve the domain using DNS first. This adds a delay that you experience when using a .local top level domain which can take up to 2 seconds.

As a workaround for that issue, Microsoft recommends to use domains that are invalid by design, such as .example, .invalid or .test. One that we found that works well is .localhost as your computer always knows how-to resolve that without asking DNS.

Another good alternative is to use a subdomain for a domain that you control. That way the DNS lookup is fast, but your folder mapping will be used instead of that subdomain. This does of course require that your computer has an active network connection.

 

Example:

VB6 Web Browser Example

 


AntView - The MS Edge WebView2 ActiveX control Date last changed: 2026/07/13