Compartilhar via


CoreWebView2Profile.ClearBrowsingDataAsync Method

Definition

Overloads

ClearBrowsingDataAsync()

Clear the entirety of the browsing data associated with the profile it is called on. It clears the data regardless of timestamp.

ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds)

Clear the browsing data of the associated profile.

ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds, DateTime, DateTime)

Clear the browsing data for the specified dataKinds between the startTime and endTime. Overload the ClearBrowsingDataAsync method to allow for additional time parameters.

ClearBrowsingDataAsync()

Clear the entirety of the browsing data associated with the profile it is called on. It clears the data regardless of timestamp.

public System.Threading.Tasks.Task ClearBrowsingDataAsync ();
member this.ClearBrowsingDataAsync : unit -> System.Threading.Tasks.Task
Public Function ClearBrowsingDataAsync () As Task

Returns

Applies to

ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds)

Clear the browsing data of the associated profile.

public System.Threading.Tasks.Task ClearBrowsingDataAsync (Microsoft.Web.WebView2.Core.CoreWebView2BrowsingDataKinds dataKinds);
member this.ClearBrowsingDataAsync : Microsoft.Web.WebView2.Core.CoreWebView2BrowsingDataKinds -> System.Threading.Tasks.Task
Public Function ClearBrowsingDataAsync (dataKinds As CoreWebView2BrowsingDataKinds) As Task

Parameters

Returns

Examples

string dataKindString = e.Parameter.ToString();
CoreWebView2BrowsingDataKinds dataKinds;
if (dataKindString == "Cookies")
{
    dataKinds = CoreWebView2BrowsingDataKinds.Cookies;
}
else if (dataKindString == "DOM Storage")
{
    dataKinds = CoreWebView2BrowsingDataKinds.AllDomStorage;
}
else if (dataKindString == "Site")
{
    dataKinds = CoreWebView2BrowsingDataKinds.AllSite;
}
else if (dataKindString == "Disk Cache")
{
    dataKinds = CoreWebView2BrowsingDataKinds.DiskCache;
}
else if (dataKindString == "Download History")
{
    dataKinds = CoreWebView2BrowsingDataKinds.DownloadHistory;
}
else if (dataKindString == "Autofill")
{
    dataKinds = (CoreWebView2BrowsingDataKinds)(CoreWebView2BrowsingDataKinds.GeneralAutofill | CoreWebView2BrowsingDataKinds.PasswordAutosave);
}
else if (dataKindString == "Browsing History")
{
    dataKinds = CoreWebView2BrowsingDataKinds.BrowsingHistory;
}
else
{
    dataKinds = CoreWebView2BrowsingDataKinds.AllProfile;
}
System.DateTime endTime = DateTime.Now;
System.DateTime startTime = DateTime.Now.AddHours(-1);

// Clear the browsing data from the last hour.
await WebViewProfile.ClearBrowsingDataAsync(dataKinds, startTime, endTime);
MessageBox.Show(this,
   "Completed",
   "Clear Browsing Data");

Remarks

Clears browsing data on the profile the method is called on. Additional optional parameters include the start time and end time to clear the browsing data between as well as the data specific data kinds to clear on the profile. The method may be overloaded to take:

- No parameters - in which the entirety of the data on the profile will be cleared. - The data kind(s) - in which the data kind(s) will be cleared for their entirety. - The data kind(s), start time, and end time - in which the data kind(s) will be cleared between the start and end time. The start time will be offset by -1.0 and the end time will be offset by +1.0 to include the last fractional second on each respective end. The start time is inclusive in the time period while the end time is exclusive.

The exposed methods are as follows:

ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds dataKinds);
ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds dataKinds, DateTime startTime, DateTime endTime);
ClearBrowsingDataAsync();

Applies to

ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds, DateTime, DateTime)

Clear the browsing data for the specified dataKinds between the startTime and endTime. Overload the ClearBrowsingDataAsync method to allow for additional time parameters.

public System.Threading.Tasks.Task ClearBrowsingDataAsync (Microsoft.Web.WebView2.Core.CoreWebView2BrowsingDataKinds dataKinds, DateTime startTime, DateTime endTime);
member this.ClearBrowsingDataAsync : Microsoft.Web.WebView2.Core.CoreWebView2BrowsingDataKinds * DateTime * DateTime -> System.Threading.Tasks.Task
Public Function ClearBrowsingDataAsync (dataKinds As CoreWebView2BrowsingDataKinds, startTime As DateTime, endTime As DateTime) As Task

Parameters

startTime
DateTime
endTime
DateTime

Returns

Applies to