Default ASP NET Core 8 port changed from 80 to 8080

Today, I learned the hard way that the default port for ASP.NET Core 8 container images has been updated from port 80 to 8080, quite a remarkable breaking change. We upgraded our web application from .NET 7 and let the CI pipeline do its work. Finally, we checked the application in the browser to ensure everything was okay, but unfortunately, we got a 502 Bad Gateway error. The Nginx logs revealed that the app was rejecting connections, which was unexpected because we didn’t make any changes there....

February 20, 2024
Early in the morning at the Microsoft House in Milan. Preparations underway

Video of my C# 12 session at .NET Conference Italia 2023

The video and slides of my C# 12 session at .NET Conference Italia 2023 is finally available online. Unfortunately it’s just my voice and my laptop screen, and that’s too bad because the location was as cool as it can get, and the room was packed. It is in Italian1 and you need to login in order to see it (sorry, I don’t have control over it.) I also submitted to several international conferences; let’s see what happens....

January 26, 2024

Fixing the "Failed to create CoreCLR error 0x80070008" error when starting a .NET 8 docker container

Another day, another unexpected problem. Launching a .NET 8 app from a docker container, I got this error: Failed to create CoreCLR, HRESULT: 0x80070008. I was puzzled as the same container ran smoothly in our test environment but not in production. I ruled out resource problems (memory or disk full, maybe?) but then compared the Docker Engine versions we run in test and production. Both were old (20. xx when 25 is available), but interestingly, the production version was older....

January 26, 2024

How to implement a PKCE code challenge in C#

Today’s fun was implementing OAuth2’s RFC 7636’s PKCE (Proof Key for Code Exchange) in C#. It’s relatively straightforward, but I decided to share my implementation should it be helpful to someone else out there. PKCE is an extension to the Authorization Code flow to prevent CSRF and authorization code injection attacks. [..] It was originally designed to protect the authorization code flow in mobile apps, but its ability to prevent authorization code injection makes it useful for every type of OAuth client, even web apps that use client authentication (source)....

January 17, 2024

FatturaElettronica for .NET v3.4.13

Today I released Fattura Elettronica for .NET v3.4.13. The Fattura Elettronica project allows for the validation and de/serialization of electronic invoices that adhere to the standard defined by Italian Revenue Agency (Agenzia Entrate). See the changelog for details (Italian).

January 8, 2024

I am speaking at the .NET Conference Italia 2023

In a few days, on Monday, December 4, at 10 a.m., I will present at the .NET Conference Italia 2023, which will be held at the Microsoft House in Milan. My session is titled “C#12 What’s new and interesting” and is part of a rich agenda focused on the recent release of .NET 8. I presented on the same subject at a DevRomagna meetup a few months ago when C# 12 was in preview and still had several moving parts....

November 23, 2023

How to use XmlWriter along with StringWriter to properly serialize a UTF-8 string

Today, I (re)learned how to serialize an XML to a UTF-8 string. Like all the other times I did this, I got backstabbed by StringWriter, which only supports UTF-16. A simple code snippet like this: await using var sw = new StringWriter(); await using var w = XmlWriter.Create(sw, new() { Async = true }); ... await w.FlushAsync(); return sw.ToString(); Will emit this output: <?xml version="1.0" encoding="utf-16"?><... There’s nothing inherently wrong with UTF-16, but XML is usually UTF-8, so one must do something about it....

November 9, 2023

FatturaElettronica for .NET v3.4.11

Fattura Elettronica for .NET v3.4.11 was released on NuGet today. The Fattura Elettronica project allows for the fixes a missing validation point. See the changelog for details (Italian). validation and de/serialization of electronic invoices following the Italian Revenue Agency standards.

October 27, 2023

LINQ DistinctBy on a property for .NET Standard and older .NET versions

Today I learned how to implement a custom Enumerable.DistinctBy extension method that returns distinct elements from a sequence according to a specified key selector function. .NET 6 and its successors have the method built in within LINQ, but I needed it in a .NET Standard 2.0 class library, so I was out of luck. My implementation is simple, not different from others I found online, and should also work fine with old ....

October 25, 2023

FatturaElettronica for .NET v3.4.10

Fattura Elettronica for .NET v3.4.10 was released on NuGet today. The Fattura Elettronica project allows for the validation and de/serialization of electronic invoices following the Italian Revenue Agency standards. This release adds a missing validation point. See the changelog for details (Italian).

August 3, 2023