Creating the local storage service
The LocalStorage
project will be created by using Microsoft’s Blazor WebAssembly App Empty project template to create an empty Blazor WebAssembly project. First, we will add a JavaScript file with the JavaScript functions that our service will need to use to update the application’s Local Storage. Next, we will create the interface and class with the .NET methods that will invoke the JavaScript functions. Finally, we will test our service by adding a collocated JavaScript file.
Create the local storage service project
We need to create a new Blazor WebAssembly app. We do this as follows:
- Open
Visual Studio 2022
. - Click the Create a new project button.
- Press Alt+S to enter the search for templates textbox.
- Enter
Blazor
and press the Enter key.
The following screenshot shows the Blazor WebAssembly App Empty
project template.
- Select the
Blazor WebAssembly App Empty
project...