(1/30) Learn Blazor Together: First Look at Blazor

(1/30) Learn Blazor Together: First Look at Blazor

The author has been in the software industry for a short time, and has encountered three architectures

Last updated 12/9/2021 10:35 PM
StrayaWorker
4 min read
Category
Blazor
Topic
Learn Blazor Together Series
Tags
.NET C# ASP.NET Core Blazor Architecture Design

I haven’t been in the software industry for long, but I’ve worked with three architectures so far: ASP.NET MVC, ASP.NET Core & Blazor, and ASP.NET Core & Angular. When I started with ASP.NET MVC as a newcomer, I was still figuring things out and just followed senior colleagues to complete projects, so I didn’t gain many insights—only a rough understanding of the front-end/back-end distinction: the front end sends HTTP requests to fetch data from the back end, the back end returns data, and the front end renders the results on the page.

When the project was wrapping up, the manager pushed for a transition to ASP.NET Core & Blazor and assigned me to create a template. I searched online resources and pieced together a workable architecture. At that time, I felt Blazor was vastly different from ASP.NET MVC—the front end no longer needed weakly typed JavaScript, and both front and back ends were strongly typed, which greatly helped my lazy nature. Unfortunately, due to client requirements, I had to switch to ASP.NET Core & Angular, so I couldn’t dive deeper into Blazor.

But every cloud has a silver lining. Under the high pressure of the new project and with guidance from colleagues, I roughly understood Angular’s Module and Component layered architecture, and Observables (similar to the concept of Ajax). Although I’m still not fully proficient, I’ve become fairly familiar with Angular and discovered that its Component concept is similar to Blazor’s—different paths, same destination.

Since my purpose in joining the Ironman competition is to document my learning experience, some descriptions may be a bit wordy. Also, I don’t have extensive experience in software development, so if there are any mistakes in my articles, please feel free to correct me.

In this Ironman competition, I plan to use Blazor to build a website where users can enter logs. The topics I expect to cover include:

  1. Introduction to Blazor
  2. The two hosting models (Blazor Server, Blazor WebAssembly) and project structure
  3. Component introduction and event handling
  4. ASP.NET Core
  5. EF Core
  6. Login and authorization

Blazor is written in C#. Although it can also be developed with VB or F#, I’m only familiar with C#. C# is part of the .NET framework, and development in Visual Studio is more convenient for .NET, so I’ll use Visual Studio, targeting .NET 5. Regarding the differences between ASP.NET, .NET Framework, and .NET Core, I saw a detailed explanation earlier that I found very helpful. If time permits, I’ll share it later. Also, I’ll use Git as version control, and the final code will be hosted on GitHub.

GitHub link

Visual Studio download link

Note: The code in this article has been refactored with .NET 6 + Visual Studio 2022. You can click the original link and compare with the refactored code for learning. Thank you for reading and supporting the original author.

Keep Exploring

Related Reading

More Articles
Same category / Same tag 12/25/2021

(29/30)Learn Blazor Together: Blazor Unit Testing

The most boring part of developing a system is probably fixing bugs, especially errors like trying to access a null object (`Object reference not set to an instance of an object.`), which is the most common problem most people encounter when they first step into programming. To break free from the tedious bug-fixing process, this article introduces `unit testing`.

Continue Reading
Same category / Same tag 12/25/2021

(28/30) Learning Blazor Together: Policy-based Authorization

It was mentioned earlier that `ASP.NET Core Identity` uses `Claim`-based authentication. In fact, `ASP.NET Core Identity` has different types of authorization methods, the simplest being `Login Authorization`, `Role Authorization`, and `Claim Authorization`. However, all of the above are implemented in one way: Policy-based Authorization.

Continue Reading