News: 1587027611

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

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

(2020/04/16)


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.

[1]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 [2]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 [3]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 [4]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.

[5]

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 [6]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."

Sponsored: [7]Legacy Modernization: Finding Your Way With Low-Code



[1] https://www.theregister.co.uk/2009/04/02/microsoft_asp_open_source/

[2] https://weblogs.asp.net/scottgu/introducing-razor

[3] https://www.theregister.co.uk/2020/01/17/webassembly_key_to_a_highperformance_web_or_ideal_for_malware/

[4] https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-3.1

[5] https://regmedia.co.uk/2020/04/15/choices.png

[6] https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/?view=aspnetcore-3.1

[7] https://go.theregister.co.uk/tl/1936/-8553/legacy-modernization-finding-your-way-with-low-code?td=wptl1936

Confusing for those that dont .NET

IneptAdept

I think as with any language when looking in from the outside the bewildering options (which they are options) can discourage a few, but come on look at Java

As a .NET dev for many years coming from the original ASP set, there was a few years where everything was confusing but now its pretty obvious

.NET Core (which is now just .NET) is the way to go for all new developments

In fact it has only got clearer as a developer in the .NET family

With a little fibbing

Steve Channell

"Blazer server" is not a real option, but instead a test framework for Blazor web-assembly for rapid development. There is also a mock browser for CI unit testing. Blazor web-assembly is held back by the conversion of Edge to chromium and distributed debugging.

Thanks

Mike Shepherd

Many thanks for these (and the earlier) detailed updates on the .NET family. They help as we try to understand the confusion emitted by Microsoft.

At its best, it is like magic

Warm Braw

I think that's part of the problem.

Write some code - and the database gets created for you. Take a database and the code gets automatically generated. Make changes and the code and the data are automatically synchronised. Now, to be fair, this has had to be simplified a bit for Core, but the more ways there are to do something, the harder it is to document and the more developers get confused about what's actually going on. Generally, I'd rather do a bit more work up front and be confident about what was happening behind the scenes - and that it wouldn't be deprecated or significantly amended in the next release.

Web Forms needs to be moved forward onto .NET Core

rmullen0

Microsoft is throwing Web Forms developers under the bus and refuses to move it forward from .NET Framework to .NET Core. I could live with having to run it on Windows. However, the problem is that .NET Framework lacks new language-level support. .NET Framework doesn't support .NET Standard 2.1 which EF Core 5 now requires. This means that you won't be able to use the latest EF Core with Web Forms applications. EF Core has had a lot of problems over the years. Problems with the query engine. Slow performance. Missing features that were in the original EF. etc. Web Forms needs to be brought forward. There are a lot of Web Forms apps out there and they aren't going to get re-written. Especially, when the newer technologies don't do what it does. Server-side Blazor is probably as close as it gets to a replacement, but, it is still immature. Also, I cannot stand the design of post Web Forms ASP.NET. It was easier to use in the old days. Personally, I am not happy at all with what Microsoft is doing with web development. Microsoft shouldn't be so quick to throw their loyal developers under the bus considering the new developers seem uninterested in their products based on the results of the StackOverflow survey. Not happy at all.

Re: Web Forms needs to be moved forward onto .NET Core

IneptAdept

I am kinda thankful web-forms is not being dragged along kicking and screaming tbh

It was good in its day but ViewState is not the way to go in these times.

Of course horses for courses and all that.

Who's to blame?

StephenDGreen

Not all the confusion is down to Microsoft. There are three major causes. Firstly there was WHATWG and HTML5. This supposedly made the browser a more standard platform for applications but introduced the living document approach to defining HTML5 and broke the existing delivery of HTML by apps. Now the browser defines the application delivery more than Microsoft. Secondly, there is Open Source and the move towards Linux away from Windows. This limits further what the application technology can do. Then, thirdly, there is the move towards Social Media. This again took the initiative away from Microsoft as companies behind social media drove the technology more than Microsoft. So all three factors are about loss of lead by Microsoft and particularly about Google gaining prominence. This has surely made the water a little muddier for developers but the payoffs might well compensate them.

Cow-tippers tipped a cow onto the server.