In the fifth article in this series, I talked about and showed how to code the communications layer for this cloud solution using Web API. In this article I’m going to add the user experience (UX) layer to maintain the ad data using ASP.NET Core using the new Blazor framework (in preview).

You can see how everything connects for this article. At this point, the only person that will be using the UX, written in Blazor, is me so I can maintain the advertisement data that will be used by my free dotNetTips.Utility Dev App that I created a few years ago for .NET developers. Let’s get going.
Blazor
Microsoft describes Blazor as a new framework for building interactive client-side web UI with .NET. It features:
- Create rich interactive UIs using C# instead of JavaScript.
- Share server-side and client-side app logic written with .NET.
- Render the UI as HTML and CSS for wide browser support, including mobile browsers.
Using .NET for client-side web development offers the following advantages:
- Write code in C# instead of JavaScript.
- Leverage the existing .NET ecosystem of .NET libraries.
- Share app logic across the server and client.
- Benefits from .NET's performance, reliability, and security.
- Stay productive with Visual Studio on Windows, Linux, and macOS.
- Build on a common set of languages, frameworks, and tools that are stable, feature-rich, and easy to use.
I want to highlight that with Blazor, you can easily create an interactive website with NO JAVASCRIPT! Coming from a structured language background, I’ve never been a fan of JavaScript since it isn’t. I’ve always avoided having to write JavaScript and now with Blazor, I don’t need to! This is the framework I’ve been waiting for a very long time. I even might enjoy creating websites again. Once I was at a meeting at Microsoft with Anders Hejlsberg, the original architect of C#, where he stated that JavaScript is completely broken and someone needs to fix it. I guess he believed that so much that he later left the C# team and created TypeScript.
The current preview of Blazor requires Visual Studio 2019 Preview and .NET 3.0. Below is the architecture of Blazor.

As you can see from the above diagram, your C# code runs in the browser using Razor Views. For a long time, in classes I teach and conferences I speak at, I have been stating that users have powerful computers now, so why not move as much of the processing to the client machine and off the backend servers? This allows these servers to process more transactions and can lead to having to stand up less servers. This is a huge cost savings, especially if you are using the cloud.
Creating A Blazor Site
Before you can create a Blazor project, go to this URL and following the instructions. https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started. After that, fire up Visual 2019 Preview and create a ASP.NET Core project and on the next screen, select the Blazor client-side template.

After the solution is created, it will look like any other ASP.NET site that uses Razor pages. The magic is in those Razor pages.
Razor Pages
If you have used Razor pages in the past, then they will look very similar. Below is the markup for the index page for the Blazor app for this article. This page shows the total number of ad clicks from the client app and a list of ads that are currently enabled.


Join the conversation! Your thoughts help the community grow.