Skip to content

Example reading and writing Json files with Blazor

Notifications You must be signed in to change notification settings

gusroitman/Blazor_Json

Repository files navigation

GitHub code size in bytes .Net Blazor

Hello! I´m Gustavo 👋

I made an example for reading and writing to/from a json file in Blazor Server

For Blazor Wasm use instead :
protected override async Task OnInitializedAsync()
    {
        provinces = await httpClient.GetFromJsonAsync<List<Provinces>>("provinces.json");
    }

For more information about these methods please consult :


You need to install MudBlazor Nuget Package.

Find the package through NuGet Package Manager or install it with following command.

dotnet add package MudBlazor

Add the following to your HTML head section, it's either index.html or _Layout.cshtml/_Host.cshtml depending on whether you're running WebAssembly or Server.

<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />

Then open Pages _Layout.cshtml (Blazor Server .NET 6), Pages_Host.cshtml (Blazor Server .NET 7) or wwwroot/index.html (Blazor WebAssembly) and include this snippet :

    <script src="_content/MudBlazor/MudBlazor.min.js"></script>

You can also include globally in your _Imports.razor file of your Blazor application and import the namespaces :

@using Mudblazor
@using Mudblazor.Services

Finally you can add the services to your program.cs like this :

builder.Services.AddMudServices();

Screenshot :

This is an image


If you have any questions feel free to ask. 🗯️

About

Example reading and writing Json files with Blazor

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published