Razor syntax reference for ASP.NET Core
Razor syntax reference for ASP.NET Core
Razor is a markup syntax for embedding server-based code into webpages.
The Razor syntax consists of Razor markup, C#, and HTML.
Files containing Razor generally have a .cshtml file extension.
Razor is also found in Razor components files (.razor).
Rendering HTML
The default Razor language is HTML.
Rendering HTML from Razor markup is no different than rendering HTML from an HTML file.
HTML markup in .cshtml Razor files is rendered by the server unchanged.
Razor syntax
Razor supports C# and uses the @
symbol to transition from HTML to C#. Razor evaluates C# expressions and renders them in the HTML output.
When an @
symbol is followed by a Razor reserved keyword, it transitions into Razor-specific markup. Otherwise, it transitions into plain C#.