Introduction to Razor Templating Engine

Portal Pages can make coding page-focused scenarios easier and more productive than using controllers and views.

This document provides an introduction to the Alliance Business Suite - Razor Templating Engine

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

To escape an @ symbol in Razor markup, use a second @ symbol:


The code is rendered in HTML with a single @ symbol:


HTML attributes and content containing email addresses don't treat the @ symbol as a transition character. The email addresses in the following example are untouched by Razor parsing:

<a href=""></a>

Implicit Razor expressions

Implicit Razor expressions start with @ followed by C# code:


With the exception of the C# await keyword, implicit expressions must not contain spaces. If the C# statement has a clear ending, spaces can be intermingled:

<p>@await DoSomething("hello", "world")</p>