The Razor Syntax
The Razor syntax refers to how you write code mixed inside your view markup. Remember that this code is meant to run on the server. The Razor syntax strives to make it easy to embed code throughout your page. If you have done this in earlier versions of ASP, you will recall things like brackets and percent signs (<% ... %>) to indicate code start and end blocks. These statements were painful to write and hard to read. Razor makes it much easier.
Razor uses the at sign, @, to indicate an inline expression of code. Typically, this is all you need to tell the engine that you intend it to process some code on your page. If you have just a single line of code, you can embed it right within your HTML. The following markup with Razor ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access