Search code examples
c#wpfdotnetbrowser

User data not persisting in DotNetBrowser component


Using DotNetBrowser in WPF app in Windows 10. When navigating to certain pages that typically save user data and use it in subsequent loads to restore your settings, it doesn't seem to be happening.

See example code here of a very simple implementation. If I use it to browse to Amazon's site and login, after closing and reopening app, I'll need to login again -- in a normal browser like Chrome, it retains my login. Is something missing in the code to enable this similar behavior?


Solution

  • To make it work, I had to set UserDataDirectory when creating engine:

          engine = EngineFactory.Create(new EngineOptions.Builder
            {
    
                RenderingMode = RenderingMode.HardwareAccelerated,
                UserDataDirectory = $"{Environment.ExpandEnvironmentVariables("%AppData%\\MyApp\\Chromium\\User Data")}",
                LicenseKey = ConfigurationManager.AppSettings["DotNetBrowserLicenseKey"],
            }
            .Build());