Show data from a RESTful JSON API in a C# Razor Page web page with Visual Studio 2022

Опубликовано: 09 Сентябрь 2022
на канале: Brandan Jones
3k
42

Read a JSON Data stream from the Internet, and display it in a C# Razor Page web page. In this video, I start with a JSON endpoint. I put the JSON data into a JSON viewer to visualize it, and then into QuickType.io to generate C# client code. I paste the C# client code into a Visual Studio 2022 project. I integrate it in a cshtml.cs file, by using HttpClient to call the API endpoint and retrieve the data as a String. I use the QuickType client to convert the string to a series of objects. I add the objects to a List, and then pass that list to the .cshtml page to display them. I iterate over the list, and show the results in an HTML table. Finally, I debug through the entire application, so that we can watch it all at its own pace. The source code from this video is freely available on GitHub at :