Background​

The XbpHtmlViewer2 class has a data folder that serves as an integral mechanism for session isolation. This feature is critical for applications using the class, which internally relies on the Microsoft WebView2 runtime. By ensuring that every process employing XbpHTMLViewer2 instances utilizes a unique data folder, the framework creates a safeguard against unwanted data cross-access. This implies that the cookies, autofill data, and cached resources of one XbpHTMLViewer2 instance are kept distinct from those of another instance operating in a different process.

Default location​

A valid data folder must be set for every WebView2 instance. By default the XbpHTMLViewer2 creates a default location as outlined below.
%TEMP%\<.exe-name>-<id>.webview2. <id> is an identifier which is unique for the process.
The exact path of the data folder is reflected in the :dataFolder instance variable of a XbpHTMLViewer2 instance.

The data folder is managed by the MS WebView2 system component and cannot be deleted until after the last XbpHTMLViewer2 instance is destroyed and the WebView2 sub-system has shut down. The exact time when a data folder is no longer in use depends on internal operations performed after the last WebView2 instance is freed and is, in fact, up to Microsoft.
The data folder is not freed automatically. It is recommended to delete out-dated data folders periodically in order to prevent WebView2-related data from accumulating inside the %TEMP% directory.

Process isolation​

Every process that creates XbpHTMLViewer2 instances by default uses a data folder that is unique to the process. This ensures that a newly created XbpHTMLViewer2 instance does not have unwanted access to form data or cookies created by another process. Also, the XbpHTMLViewer2 instances used in an application run as an isolated entity and are unaffected by the operations performed in XbpHTMLViewer2 instances created in other processes.

Note that processes using the same data folders for their XbpHTMLViewer2 instances would be implicitly coupled via this folder. As a result these instances would not only access the same cache and data location, but access to this location would also be implicitly synchronized via a shared component within the MS WebView2 runtime.

Note: depending on your needs, you can redefine the data folder so that the same session store is used by XbpHTMLViewer2 instances created in multiple processes. But keep in mind that there are scenarios where sharing the data folder is not possible. One such scenario is running multiple application instances using the Remote Desktop Protocol (RDP).