Razor Pages – Umlaute werden nicht korrekt angezeigt

Wenn in Razor Pages beim Ausführen des Projekts Umlaute nicht richtig angezeigt werden kann das daran liegen, dass die Datei mit dem falschen Encoding gespeichert wurde. Um dieses zu checken kann man einfach in Visual Studio auf Datei -> Speichern unter klicken. Im Speichern Dialog ist neben dem Speichern Button ein kleiner Pfeil nach unten. Wenn man diesen anklickt gibt es die Option Mit Codierung speichern. Dieses wählt man aus.

Im Anschluss wird man gefragt, ob man die vorhandene Datei ersetzen möchte. Dieses bejaht man. Nun öffnet sich ein Dialogfenster (siehe Screenshot) in dem man die Codierung auswählen kann. Unicode (UTF-8 mit Signatur) – Codepage 65001 sollte hier die Wahl sein und diese Auswahl bestätigt man mit OK. Wenn man nun das Projekt erneut startet sollten die Umlaute korrekt dargestellt werden.

Auswahl der Codierung für eine Razor Page Datei im Dialogfenster.
Auswahl der Codierung für eine Razor Page Datei im Dialogfenster.

Getting started with Blazor

Blazor – Microsoft’s new web technology. I read a lot about the new possibilities and decided to get started with Blazor. My first step was visiting https://docs.microsoft.com/de-de/aspnet/core/blazor/get-started?view=aspnetcore-3.0&tabs=visual-studio to get all information about how to install Blazor and how to programm my first code example. I downloaded the latest version of the .net Core SDK v3.0.0-preview9 from https://dotnet.microsoft.com/download/dotnet-core/3.0 and installed the Blazor templates by command shell.

dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview9.19424.4

Now I wanted to create a new project and select Blazor as template. But there were no .net core 3 templates in the selection only core 2.1 and 2.2 project templates. Afterwords I tried many things to get it working but nothing helped.

Solution: I should have read the instructions in a better and more sensible way. I missed an important detail: The latest .net Core 3 preview version only works with the latest Visual Studio preview version.

.net Core SDK download page
.net Core SDK download page

My installed version of Visual Studio was Community Edition 16.2.5. No chance to run the latest SDK version. I had to deinstall SDK 3 preview 9 and installed v3.0.0-preview6 because this SDK version supports Visual Studio 2019 v16.2.

Coming back to Visual Studio and creating a new project I could choose from .net Core 3 templates as expected.