0

I'm about to release an app that shows a self-coded website with Google's model-viewer library. To prevent lurkers from stealing the 3D assets shown on that website, I started coding a C# application that launches WebView2 with some authentication parameters (so only that app is allowed to access the website). Sadly I've been told that the application downloads the 3D models immediately into cache. This is a huge issue I must prevent.

I've added several no-cache headers to the website. Isn't there any option to disable the WebView2 cache, or programmatically remove cached objects after a certain action happened? Or any way to encode/decode those files?

The WebView2 documentations don't cover any of these informations.

Thanks in advance.

dmkrtz
  • 1
  • 1
  • 1
  • `launches WebView2 with some authentication parameters (so only that app is allowed to access the website)` what's preventing a user from seeing this call? IMHO, you have more than just the cache issue you're speaking of. – Trevor Aug 19 '21 at 14:33
  • 2
    See "Option 2" in https://stackoverflow.com/questions/66500241/webview2-site-not-loading/66501901#66501901 which shows how to specify a location for the cache. Delete desired objects when finished with WebView2. Deleting the entire WebView2 cache each time your app closes will result in slower loading of WebView2 the next time because the cache needs to be created again. – Tu deschizi eu inchid Aug 19 '21 at 14:37
  • Thanks for your replies. The intention behind what I'm trying is that the 3D models should not be usable on the user's local PC. They should only be visible and usable in the application itself. Right now someone just has to search for a file that is >Xmb, add a .glb extension to it and it's accessible for anyone. That should be prevented at any cost. – dmkrtz Aug 19 '21 at 15:34

1 Answers1

2

Create a method/sub that can be called when FormClosed.

C# Sample

private async void ClearBrowserCache()
{
    await this.wbMain.CoreWebView2ProfileClearBrowsingDataAsync();
}

VB Sample

Private Async Sub ClearBrowserCache()

    Await Me.wbMain.CoreWebView2.Profile.ClearBrowsingDataAsync()

End Sub

Check out the other options for Clearing browsing data from the user data folder.

https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/clear-browsing-data?tabs=csharp

C# and C++ Examples are provided. VB.NET examples are not available, but the equivalents can be determined by navigating the CoreWebView2 object properties.

mapadm
  • 21
  • 4