MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
452 stars 55 forks source link

incognito mode support #779

Closed ztextplus closed 1 year ago

ztextplus commented 3 years ago

I need WebView2 to support incognito mode. Is there a solution?

AB#31044529

hunkydoryrepair commented 3 years ago

This has come up before and the response was you need to do it on your own by deleting the data from user folder.

jasonstephen15 commented 3 years ago

Hi @ztextplus, I'd like to understand your use case some more. Do you mind expanding on what your app is trying to do and how its planning on using incognito mode? Is your app a browser, trying to replicate edge's incognito experience?

ztextplus commented 3 years ago

@jasonstephen15 We use Webview2 in our client to run web applications. If the user logs in to our client and does not choose to save the username and password, we want to run Webview2 in incognito mode so that no cache data will be saved to the file.

We tried to delete the cache folder when we exited, but because the cache folder is occupied by Webview2, it cannot be deleted successfully every time.

jasonstephen15 commented 3 years ago

Does an api to manage/clear cache work for your purposes? Assuming this api works during runtime would it be a workaround to a full fledged 'incognito mode'?

ztextplus commented 3 years ago

@jasonstephen15 If Webview2 can provide an API, it is also an acceptable solution, because Webview2 itself can release the file occupation first, and then clear the cache files.

danyi1212 commented 3 years ago

I'm also searching for Incognito support in order to avoid the IIS Windows Authentication with the credentials of the logged on user. Do you have any idea how can I do so?

djlorentz commented 3 years ago

Hi @jasonstephen15, I also want to avoid caching entirely.

My use case is we that are providing user tablets that allow access to PII with HIPAA style regulations on privacy. The tablets are deployed in a kiosk style mode where the end user shell is the browser app. We do not want any caching on disk so if a tablet is lost we have not lost PII (we can revoke device access to the backend resources at the server side).

Currently we are using the cefsharp browser component with the in memory cache backend but would like to move to webview2 evergreen to use the windows update process to keep the browser component patched.

Providing the same in memory cache as cefsharp by default would also help with #297 and possibly #299

hunkydoryrepair commented 3 years ago

What does HIPAA say about the swap file? Do you disable the swap file to prevent PII from getting written there? You probably will need to create a RAM disk to use as a cache location. Modern browsers just won't function without some kind of cache, but I'm in a similar position. Our app is also kiosk mode and so need to eliminate personal information from just auto-filling. With all the privacy concerns these days I'm surprised Edge team is so careless with it. But that's more an Edge issue and WebView2 team is trying to work around their decisions.

vmeganathan81 commented 3 years ago

Do we have an ETA for this feature ?

vmeganathan81 commented 3 years ago

@jasonstephen15 , do we have an ETA for this feature ?

vmeganathan81 commented 3 years ago

We use Webview2 in our client to run web applications. If the user logs in to our client and does not choose to save the username and password, we want to run Webview2 in incognito mode so that no cache data will be saved to the file.

We tried to delete the cache folder when we exited, but because the cache folder is occupied by Webview2, it cannot be deleted successfully every time.

Same here as well, do we know when would this feature be available, I see the last update in Dec 2020

vmeganathan81 commented 3 years ago

@david-risney , any update on this feature.

david-risney commented 3 years ago

We may be looking into it in the near future. I don't have any specific dates though.

neostfox commented 3 years ago

wait for this

nirdil commented 2 years ago

Why not just run from a new temporary user data folder in that case? Something like this before creating the webview:

 Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", Path.Combine(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Incognito", new Random().Next().ToString())));

Also, I'm not sure if that suffices but for real incognito you should also disable MS SmartScreen:

 Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--disable-features=msSmartScreenProtection");
LucaZiegler commented 2 years ago

Why not just run from a new temporary user data folder in that case? Something like this before creating the webview:

 Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", Path.Combine(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Incognito", new Random().Next().ToString())));

Also, I'm not sure if that suffices but for real incognito you should also disable MS SmartScreen:

 Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--disable-features=msSmartScreenProtection");

Thank you, you are a genius! I can now use multiple MSAL accounts to login and use them for the Graph API.

marekpetak commented 2 years ago

Any news on this? The above solution is OK, but not what I would expect from the API. We should have something like

webView.EnableIncognito = true;

or

webView.ClearChache();

Thanks

mayur-agarwal-lrn commented 2 years ago

I am waiting for private mode too or clear cache/cookies. Any updates on this feature request?

david-risney commented 2 years ago

InPrivate is supported via the CoreWebView2ControllerOptions.IsInPrivateModeEnabled

mayur-agarwal-lrn commented 2 years ago

How to use it in a WPF application with a WebView2 control in it? Can you point to any documentation? As far as I have researched, ControllerOptions are not available for the control.

champnic commented 1 year ago

For WPF you can initialize the control using EnsureCoreWebView2Async(CoreWebView2Environment, CoreWebView2ControllerOptions) instead of using the Source property. https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.wpf.webview2.ensurecorewebview2async?view=webview2-dotnet-1.0.1518.46#microsoft-web-webview2-wpf-webview2-ensurecorewebview2async(microsoft-web-webview2-core-corewebview2environment-microsoft-web-webview2-core-corewebview2controlleroptions)

vmeganathan81 commented 1 year ago

It's available now..?

vmeganathan81 commented 1 year ago

@champnic is it available now, if yes could you share link for samples

champnic commented 1 year ago

Yes this is available now. I linked the APIs above, and here is the sample (in Win32): https://github.com/MicrosoftEdge/WebView2Samples/blob/1710d535e895ed9c24196c5482e990e10d7285c7/SampleApps/WebView2APISample/AppWindow.cpp#L1343