To switch from HTML mode to C# mode an @ is used, when the expression becomes more complex you need to add parentheses around it!
DateTime: 12/28/2025 02:10:11
Some calculation 28 *6/3 + 1
Some calculation 20
Hello World! + "!!!"
Hello World!!!!
Joris Lops
The Razor engine is smart, most of the time it understands when to switch from HTML mode to C# mode.
Take a look at the Weather.razor code, here we need to add an @ sometimes.
Tip: use the comment/uncomment shortcut to create a comment (ctrl + /) in Rider.
Display html from C# string.
Some html from C# string
Render fragments are used to render a part of the page.
Hello World!
Render fragments with parameters.
Hello Joris!