
ASP.NET Core 5 for Beginners
By :

The beauty of Razor, compared to other templating view engines, is that it minimizes the code required when constructing your views or content pages. This enables a clean, fast, and fluid coding workflow to boost your productivity when composing UIs.
To embed C# code into your Razor files (.cshtml
), you need to tell the engine that you are injecting a server-side code block by using the @
symbol. Typically, your C# code block must appear within the @{…}
expression. This means that as soon as you type @
, the engine is smart enough to know that you are starting to write C# code. Everything that follows after the opening {
symbol is assumed to be server-side code, until it reaches the matching closing block }
symbol.
Let's take a look at some examples for you to better understand the Razor syntax basics.
In a typical ASP.NET Core MVC web application generated from the default template, you'll see the...