Compartilhar via


CoreWebView2Profile.ClearCustomDataPartitionAsync(String) Method

Definition

Clears all DOM storage and cookies in the specified custom data partition.

public System.Threading.Tasks.Task ClearCustomDataPartitionAsync (string CustomDataPartitionId);
member this.ClearCustomDataPartitionAsync : string -> System.Threading.Tasks.Task
Public Function ClearCustomDataPartitionAsync (CustomDataPartitionId As String) As Task

Parameters

CustomDataPartitionId
String

The id of the custom data partition. If null or empty string is specified, ArgumentException will be thrown.

Returns

Examples

var dialog = new TextInputDialog(
    title: "Clear Custom Data Partition",
    description: "Enter Custom Data Partition Id to clear",
    defaultInput: _iWebView2.CoreWebView2.CustomDataPartitionId);
if (dialog.ShowDialog() == true)
{
    try
    {
        await WebViewProfile.ClearCustomDataPartitionAsync(dialog.Input.Text);
        MessageBox.Show(this,
           "Completed",
           "Clear Custom Data Partition");
    }
    catch (Exception exception)
    {
        MessageBox.Show(this, "ClearCustomDataPartitionAsync Failed: " + exception.Message, "Clear Custom Data Partition");
    }
}

Remarks

Clears all DOM storage and cookies in the custom data partition identified by the CustomDataPartitionId. If no partition is found for the specified CustomDataPartitionId, the API succeeds without doing anything.

As DOM storage and cookies in the custom data partition is also browsing data, they will also be cleared when @CoreWebView2Profile.ClearBrowsingDataAsync is called and the clearing condition is met.

Applies to