Razor Syntax

Learn the basics of the Razor syntax of inline expressions, control structures, conditional statements, and loops.

Razor syntax is made up of HTML, Razor markup, and C#. Rendering HTML from a Razor component is the same as rendering HTML from an HTML file. The HTML in a Razor component is rendered by the server unchanged. Razor syntax uses both inline expressions and control structures.

Inline expressions

Inline expressions start with an @ symbol followed by a variable or function name. This is an example of an inline expression:

Get hands-on with 1400+ tech skills courses.