Last week I promised to let you know what you--that is, at least some of you--told me what you thought about React or Blazor as a front-end replacement for Web Forms applications.
If you haven't read it, the TL;DR is I asked folks about their preferences and Blazor took the win by a large majority. I will say, however, that a considerable percentage were on the virtual fence: don't care, don't know, or not applicable.
Before I get into specifics, let's take a peek at the differences between these two web front-end solutions. Note both of them are client-centric, as opposed to a lot of more traditional (ASP.NET I'm looking at you) architectures that require server round trips for much of the UI view updates.
Blazor is a web framework developed by Microsoft that allows developers to build web applications using C# and .NET. Blazor eliminates the need for JavaScript and enables developers to leverage their existing knowledge of C# to build full-stack web applications. Basically Blazor runs C# in the browser, using something called WebAssembly. Moving from Webforms to Blazor means you (theoretically) can re-use a lot of your existing app's C# code. WebAssembly is a .NET runtime that works in all modern browsers and runs .NET assemblies. Think Adobe Flash without the malware. Cool, huh?
Just like ASP.NET and Webforms, Blazor code lets you mix HTML and C# code together, like in the following example, where you have HTML calling a C# method to increment a variable.
@page "/counter" <PageTitle>Counter</PageTitle> <h1>Counter</h1> <p role="status">Current count: @currentCount</p> <button class="btn btn-primary" @onclick="IncrementCount">Click me</button> @code { private int currentCount = 0; private void IncrementCount() { currentCount++; } }
Blazor has gained a lot of traction since launch, mainly because of the tight integration with .NET and also because it is fast.
React is a widely-used front-end framework developed by Facebook. It is a JavaScript library that allows developers to build user interfaces for web applications. React follows a component-based architecture, where reusable components are created and composed to create complex UIs.
React uses a virtual DOM (Document Object Model), which allows for efficient rendering of UI components. React updates only the necessary parts of the DOM when changes occur, resulting in improved performance and a smoother user experience. This is similar to a technique we (Mobilize.Net) use in our WebMAP architecture, where we update UI elements selectively.
Another aspect of React is its support for JSX (JavaScript XML), which allows developers to write HTML-like code directly within JavaScript. This simplifies the process of creating UI components and enhances code readability. Or so they say. Anyway, some of the biggest apps like Facebook, Twitter, and Airbnb use React for their front-end code.
Here, courtesy of react.dev/learn is a React sample that declares a JS function and then displays/formats it in HTML. Also cool, huh?
function MyButton() { return ( <button> I'm a button </button> ); } export default function MyApp() { return ( <div> <h1>Welcome to my app</h1> <MyButton /> </div> ); }
So let's cut to the chase, and find out what you--the developer public--actually said.
What did folks say about their choices? Some of the more common or interesting points I heard below:
And finally, this response: We don’t have any have legacy ASP.NET web forms apps. One thing in our favor.
There you have it, right from the source.
Got Web Forms? Want something better? Check out our offerings here.