> For the complete documentation index, see [llms.txt](https://docs.wisej.com/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/api/wisej.core/general/wisej.core.browserstorage.md).

# BrowserStorage

Namespace: **Wisej.Core**

Assembly: **Wisej.Framework** (4.0.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

### ![](/files/hsR4ok3152WyAf8J2C1u) Clear()

Removes all the values from the browser's storage.

### ![](/files/hsR4ok3152WyAf8J2C1u) GetKeys(callback)

Returns all the keys in the browser's storage.

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

### ![](/files/hsR4ok3152WyAf8J2C1u) GetKeysAsync()

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

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

### ![](/files/hsR4ok3152WyAf8J2C1u) 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/dotnet/api/system.string)       | Key associated with the value to retrieve.              |
| **callback** | [Action\<T>](https://docs.microsoft.com/dotnet/api/system.action-1) | 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/dotnet/api/system.argumentnullexception)\
  The *key* is null or empty, or *callback* is null.

### ![](/files/hsR4ok3152WyAf8J2C1u) 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/dotnet/api/system.string) | Kay associated with the value to retrieve. |

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

### ![](/files/hsR4ok3152WyAf8J2C1u) RemoveValue(key)

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

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

### ![](/files/hsR4ok3152WyAf8J2C1u) 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/dotnet/api/system.string) | Key associated with the value.           |
| **value** | [T](/api/wisej.core/general/wisej.core.browserstorage.md)     | Value to store in the browser's storage. |

## Inherited By

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
