Sunday 26 January 2020

0. Starting Out - Migrating to Blazor

Blazor

This blog assumes that you've already looked at Blazor. There are lots of videos and demos out there which cover what Blazor is, the various implementations (client-side, server-side, etc) and how it works, so I'm not going to cover what so many other excellent resources have already done.

If you haven't, I'd recommend the main Microsoft site Blazor.net and also the excellent resource site Awesome Blazor. If you want a pointer to which of the various intro videos to watch, I'd recommend the 'inventor' Steve Sanderson's NDC Oslo talk in July 2019. There was also the recent .NET Conf - Focus on Blazor which covers a lot of different topics.

Not a Newbie?

OK! So you've looked at the videos, played around with some simple apps, read some documentation. How do you migrate an existing application from either ASP.NET WebForms or MVC?

That's what this blog is about - the real-world adventures of migrating an application to Blazor.

EMS

The application we are going to port to Blazor is an ASP.NET MVC website we built called EMS, which stands for Energy Management System.

This is a site that allows our clients to store details of their business sites, gas and electricity meters, supplier contracts and energy bills.

The current application in ASP.NET MVC written using .NET Framework 4.7.2. It's a modular tiered application which uses several packages we have written for data access, business logic, security etc. It also uses several third-party Nuget packages. On the client, we use TypeScript to write our client-side JavaScript functionality and various layouts and screens.

Key Steps in Migrating

If you're starting from a similar position and want to migrate your web application to Blazor, you'll need to consider the following issues:
  • Converting to .NET Standard 2.0
  • Updating Nuget package dependencies to versions that will work on this
  • The Build process
  • Authentication and Security
  • Server vs Client Side
We'll cover these initial steps in a series of posts (1-5), and then I'll go on to discuss the challenges we face in converting from ASP.NET to ASP.NET Core with Blazor.

5 - Adding Blazor

So in the previous step 4, we had upgraded our application to ASP.NET Core 3.1, but we still had no actual Blazor anywhere in the system. Ho...