Razor expression
A Razor expression is an inline construct that evaluates an embedded C# expression and inserts its result into generated output.
Pro ASP.NET Core 7, Tenth Edition
A Razor expression is an embedded expression in a Razor view that Razor evaluates to produce content in the generated response.
- How it is used
- Inserts evaluated C# values into HTML responses generated by Razor views and Razor Pages.
- How deep it goes
- Works through property access, method calls, arithmetic boundaries, and attributes, then identifies generated C# calls without tracing compilation in detail.
- Examples
- Uses a product table, currency formatting, contrasting tax calculations, a rendered data-id attribute, and page-model property access.
- What you can do after
- Build it from scratch in a .cshtml view to insert model values and avoid mistaking arithmetic for literal content.
Read how Pro ASP.NET Core 7, Tenth Edition explains razor expression →
ASP.NET Core in Action, 3e
A Razor expression is an inline Razor construct that evaluates a C# expression and writes its result to the generated HTML output.
- How it is used
- Renders C# values from Razor Pages models or ViewData directly into dynamic HTML.
- How deep it goes
- Defines @, @(), and @@ syntax, contrasts expressions with @{} code blocks, and extends into loops and conditionals.
- Examples
- Uses copyright text, arithmetic output, and a to-do list rendered conditionally from model data.
- What you can do after
- Apply it via Razor syntax to render model values and generate data-dependent HTML without manually building response strings.
Read how ASP.NET Core in Action, 3e explains razor expression →
Related concepts
- viewused by · A view is a presentation component or template that renders application data into a user-interface element or client response.
- view modeluses · A view model is a data structure that supplies a user-interface view with the data required to render a particular output.
- attributeuses · An attribute is a named property, value, or piece of information associated with an entity, object, or program element.
- HTMLproduces · HTML (HyperText Markup Language) is the standard markup language for structuring content and elements in web documents.
- data attributeuses · An HTML data attribute is a custom attribute whose name begins with data- and whose value stores application-specific information on an element.
- methoduses · A method is a callable operation associated with an object or type and invoked through that association.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

