Is this an ASP.NET Core I see before me? Where to next for Microsoft's confusing web framework...

Too many choices?

Microsoft's ASP.NET Core, a web application framework (or more accurately, a family of frameworks), has made strides in performance and innovation, but its rapid development has resulted in a bewildering range of choices facing developers.

The original ASP.NET was launched simultaneously with .NET itself, way back in 2002, co-developed by Microsoft’s Scott Guthrie and Mark Anderson. It was a replacement for the COM-based Active Server Pages. Perhaps the best and worst thing about ASP.NET 1.0 was the form-based programming model that (somewhat) handled state management for you, making it an easier transition for desktop developers, but with downsides in areas like unit testing, responsive user interfaces, and compatibility with modern JavaScript libraries. Now called web forms, this approach is still popular, but limited to the Windows-only .NET Framework.

In early 2009 Microsoft launched ASP.NET MVC, a new framework based on the model-view-controller pattern. It had many advantages over web forms, including better performance, easy integration with JavaScript, amenable unit testing, and a cleaner programming model. Although it was widely adopted in the .NET community, some developers preferred to stick with the mature web forms approach. Further confusing matters, it is possible to combine MVC and web forms, by using MVC routing with web forms pages.

As ASP.NET MVC evolved, Microsoft developed the Razor syntax for View pages. Razor lets you combine C# code and HTML mark-up with minimal ceremony. Razor was initially used for ASP.NET MVC but soon took on a life of its own, with support for projects that use Razor pages but without the MVC pattern.

Then came .NET Core and ASP.NET Core, first fully released in 2016, Microsoft's official cross-platform and open source implementation of .NET. The company implemented ASP.NET Core MVC, but not web forms.

To Blazor with you

In 2018, a new approach called Blazor joined the fray. Blazor began life with the Xamarin (.NET for mobile and Mac) team at Microsoft, who were working on compiling the Mono .NET runtime to WebAssembly. The name is a combination of Browser and Razor. The initial idea was to have a framework for single page applications (SPAs) written in C# and running in the browser. Developers could write C# everywhere, as opposed to mixing C#, JavaScript and perhaps TypeScript. Visual Studio, the primary tool for developing with ASP.NET, is a much better editor for C# than it is for JavaScript.

Blazor was released as part of .NET Core 3.0 in September 2019, by which time it had somewhat changed shape. The initial release is for Blazor server-side applications, which does not use WebAssembly at all. Instead, Razor components run on the server and update the browser user interface via SignalR, Microsoft's framework for real-time communications.

Blazor WebAssembly is in preview. The code the developer writes for Blazor Server or Blazor WebAssembly is pretty much the same, but the outcome is very different. As the documentation notes, with Blazor Server, "Higher latency usually exists. Every user interaction involves a network hop." Blazor Server also has advantages, with smaller download size and no requirement for WebAssembly support, but the WebAssembly option looks more attractive for most scenarios.

There is also ASP.NET Web API, a framework for building REST APIs with models and controllers adapted from ASP.NET MVC, which is suitable for serving data to mobile as well as web applications.

Microsoft presents some of the choices for ASP.NET Core

Strong features of ASP.NET Core are that it is cross-platform, well suited to container deployment, and easily tested. Another key feature is dependency injection, where classes do not directly create instances of the service objects on which they depend, but have them passed to them, usually in the constructor. This achieves loose coupling, a good principle but one which can be confusing for beginners. Tooling for ASP.NET Core is flexible, a far cry from the days when developing outside Visual Studio was painful. Today you can also use Visual Studio for the Mac, the cross-platform Visual Studio Code, or any text editor.

Microsoft's web platform is not as confusing as its desktop platform, but does present developers with a confusing array of choices. One of them, ASP.NET MVC, is not quite deprecated but heading in that direction. Microsoft's documentation now says that: "For new development, we recommend Razor Pages over MVC with controllers and views."

In fact, the documentation authors cannot keep up with all the permutations. The page referenced above, a tutorial for data access with ASP.NET MVC, states that "There is a Razor Pages version of this tutorial. Each tutorial covers some material the other doesn't."

Architecture choices

The company offers a free book [PDF] on architecting ASP.NET Core applications which offers some clues about how Microsoft sees these choices. Web Forms, it says, "continues to be a robust and reliable platform." Blazor "provides a rich client experience," and is ideal where "your team is more comfortable with .NET development than JavaScript or TypeScript."

Traditional web applications (like ASP.NET MVC or Razor Pages) are aimed at simple applications or where teams are unfamiliar with JavaScript or TypeScript. SPAs are for rich experiences but "require greater architectural and security expertise," said the author Steve Smith. The book is a good read for newcomers trying to make sense of the platform overall, with explainers on all the essential pieces, including commonly used JavaScript frameworks like jQuery, Angular, React.js and Vue.js.

Architecting an ASP.NET application: a handy book for navigating the key concepts

Steve Gordon, a senior .NET developer at Brighton-based Madgex, which develops recruitment software, is also a .NET trainer and has been using ASP.NET since its first introduction. He now uses ASP.NET Core and says "it's a very efficient product to work with, we can build out microservices very quickly and very easily with it."

He says the platform is not so confusing if you have followed it through the various changes. What does he think of Blazor? "I can see that it might be an easier onboarding experience for someone experienced in building single-page apps with Node.js to make a transition, as well as to help .NET developers that are more familiar with C# to continue coding and working in the browser," he told The Register.

One of the issues with ASP.NET Core is that new releases bring breaking changes. Gordon says that part of the solution for enterprise developers is to note Microsoft's different support models for long term support (LTS) releases. For example, .NET 3.0 is not an LTS release, but .NET 3.1 is. The policy is laid out here. "I've seen developers fall into the trap that they adopt the latest current release not realising that the support will run out soon, where Microsoft has historically supported things much longer."

Microsoft does tend to tangle ASP.NET Core with another of its frameworks, the database object-relational mapping technology called Entity Framework EF Core. At its best, it is like magic: developers simply write C# classes to represent data, and EF generates the tables and lets developers work with C# objects rather than having to think about the database. There are a number of snags, though. If you take a naïve approach to using EF Core, performance often becomes a problem, and the simplicity tends to dissolve where relationships are complex. It may not work well if you use databases other than Microsoft's SQL Server, for which it is a kind of marketing tool.

The issue is nicely expressed here, by DevOps engineer Michael Hoagland: "If you want to let your applications actually use even a fraction of what you’re paying those huge licensing fees for, stop constraining SQL to an EF driven hellish wasteland of something little better than SELECT *."

Hoagland argues that EF can be used efficiently, but that this is rarely the case, in part because Microsoft's documentation leads developers down the wrong path.

Developers in search of better performance may wish to look at Dapper, a thin object mapper for .NET that requires developers to know their SQL, but in return delivers much faster results.

StackOverflow survey shows that while developers enjoy working with ASP.NET, it doesn't appeal strongly to those not yet using it

The most recent StackOverflow technology survey shows ASP.NET used by 26.3 per cent of respondents, scoring 64.9 per cent for "most loved" and 35.1 per cent for "most dreaded." These are not bad figures, but most telling is that the platform scores only 3.7 per cent under "most wanted,” supporting a suspicion that while Microsoft’s move towards open source and cross-platform with .NET Core and ASP.NET Core have helped developers like Gordon stay on board with the company’s web platform, it has not been so successful in attracting new developers from elsewhere. One of the issues, perhaps, is that Microsoft tends to present it as part of a package including Entity Framework, SQL Server and even Azure. That must be good for product adoption, but does conflict with its effort to appeal to a wider community. ®

Send us news

Google wants regulators to take Microsoft down a notch before it stifles AI

Ad giant that owns over 80 percent of search traffic yells at cloud monopoly

Preview edition of Microsoft OS/2 2.0 surfaces on eBay

Discounted from $2,600 down to just $650. What a bargain!

Microsoft Publisher books its retirement party for 2026

Venerable desktop publisher not going to get a Copilot any time soon

Microsoft retires Azure IoT Central retirement announcement

And fails to clear up end-of-life debacle

Musk 'texts' Nadella about Windows 11's demands for a Microsoft account

Billionaire worried about AI crawling over his computer

Europe probes Microsoft's €15M stake in AI upstart Mistral

Cash-for-Azure-access deal went through just as latest LLM landed

Microsoft's February Windows 11 security update unravels at 96% for some users

Was your Patch Tuesday followed by a Rollback Wednesday? You're not alone

Windows 11 users herded toward 23H2 via automatic upgrade

Machine learning to smooth bumps in the update road

The Who’s Who of AI just chipped in to fund humanoid robot startup Figure

$675 million to accelerate development of machine that can lift, but can’t keep up with humans

Microsoft says it'll throw €3.2B at AI ops in Germany

What's the wurst that could happen?

What is GitHub Copilot Enterprise? You and your org just might find out firsthand

Big biz invited to like and subscribe, without fear of litigation

Microsoft warns Dev Drive daredevils to back up or beware after latest build

Rolling back will cause data loss, Windows Insiders told