# BrowserStorage

Namespace: **Wisej.Core**

Assembly: **Wisej.Framework** (3.1.0.0)

Represents the browser's storage objects.

{% tabs %}
{% tab title="C#" %}

```csharp
public class BrowserStorage : IWisejSynchronized
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class BrowserStorage
    Inherits IWisejSynchronized
```

{% endtab %}
{% endtabs %}

## Methods

### ![](https://3858804530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1zeuyneJ2f5i3NKcg6us%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)Clear()

Removes all the values from the browser's storage.

### ![](https://3858804530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1zeuyneJ2f5i3NKcg6us%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)GetKeys(callback)

Returns all the keys in the browser's storage.

| Parameter    | Type                                                                             | Description                                                 |
| ------------ | -------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| **callback** | [Action\<String\[\]>](https://docs.microsoft.com/en-us/dotnet/api/system.action) | Callback method that receives each key name asynchronously. |

### ![](https://3858804530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1zeuyneJ2f5i3NKcg6us%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)GetKeysAsync()

Asynchronously returns all the keys in the browser's storage.

**Returns:** [Task\<String\[\]>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task). An awaitable [Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation.

### ![](https://3858804530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1zeuyneJ2f5i3NKcg6us%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)GetValue\<T>(key, callback)

Returns the value stored in the browser's storage associated with the specified *key* .

| Parameter    | Type                                                                    | Description                                             |
| ------------ | ----------------------------------------------------------------------- | ------------------------------------------------------- |
| **T**        |                                                                         | Type of the value to retrieve.                          |
| **key**      | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)     | Key associated with the value to retrieve.              |
| **callback** | [Action\<T>](https://docs.microsoft.com/en-us/dotnet/api/system.action) | Callback method that receives the value asynchronously. |

This method returns the value asynchronously because it waits for the browser to respond.

```csharp

Application.LocalStorage.GetValue<string>("userName", (value) => {
  if (value != null)
    AlertBox.Show($"Welcome back, {value}");
});

```

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception) The *key* is null or empty, or *callback* is null.

### ![](https://3858804530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1zeuyneJ2f5i3NKcg6us%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)GetValueAsync\<T>(key)

Asynchronously returns the value stored in the browser's storage associated with the specified *key* .

| Parameter | Type                                                                | Description                                |
| --------- | ------------------------------------------------------------------- | ------------------------------------------ |
| **T**     |                                                                     | Type of the value to retrieve.             |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | Kay associated with the value to retrieve. |

**Returns:** [Task\<T>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task). An awaitable [Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1) that represents the asynchronous operation.

### ![](https://3858804530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1zeuyneJ2f5i3NKcg6us%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)RemoveValue(key)

Removes the value associated with the *key* from the browser's storage.

| Parameter | Type                                                                | Description                             |
| --------- | ------------------------------------------------------------------- | --------------------------------------- |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | Kay associate with the value to remove. |

### ![](https://3858804530-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1zeuyneJ2f5i3NKcg6us%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)SetValue\<T>(key, value)

Stores the specified *value* in the browser's storage.

| Parameter | Type                                                                              | Description                              |
| --------- | --------------------------------------------------------------------------------- | ---------------------------------------- |
| **T**     |                                                                                   | Type of the value to store.              |
| **key**   | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)               | Key associated with the value.           |
| **value** | [T](https://docs.wisej.com/api/v3.1/wisej.core/general/wisej.core.browserstorage) | Value to store in the browser's storage. |

## Inherited By

| Name                                                                                           | Description                                                                                                                                                    |
| ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [LocalStorage](https://docs.wisej.com/api/v3.1/wisej.core/general/wisej.core.localstorage)     | Represents the browser's localStorage. Use this class through the [Browser](https://docs.wisej.com/api/v3.1/wisej.web/general/application#browser) instance.   |
| [SessionStorage](https://docs.wisej.com/api/v3.1/wisej.core/general/wisej.core.sessionstorage) | Represents the browser's localStorage. Use this class through the [Browser](https://docs.wisej.com/api/v3.1/wisej.web/general/application#browser) instance.   |
| [CookieStorage](https://docs.wisej.com/api/v3.1/wisej.core/general/wisej.core.cookiestorage)   | Represents the browser's cookie storage. Use this class through the [Browser](https://docs.wisej.com/api/v3.1/wisej.web/general/application#browser) instance. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/v3.1/wisej.core/general/wisej.core.browserstorage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
