O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required