version:ASP.NET Core Blazor Server 3.x
using Httpclient+using System.Net.Http.Json; //for client.GetFromJsonAsync using System.Text.json; //for
Table of Content
Project Library for Service
Project Web Api
Project Blazor 3.x(Server-side)
Project Web Api
1. Project Library for Service
step 1: write service
2. Project Web Api
step 2:inject services
step 3: Add api Controller
step 4: call web api for test
output:
Project Blazor Server 3.x(Server-side)
step 5:Reference the System.Net.Http.Json NuGet package in the project file.
step 6: Add List.Razor
for version 3.1.301 I think the package location has changed.Currently, the namespace is: System.Net.Http.Json.
That will give you access to: HttpClientJsonExtensions
A. If you want to put that code into a separate class within your Blazor WebAssembly project, all you need is to put this at the top of your class file:
Obviously these extension methods are doing serialization, but what's interesting is that the package doesn't depend on Newtonsoft.Json because it uses the new System.Text.Json instead.