ASP.NET Razor - Markup
- Previous Page WebPages Assistant
- Next Page Razor Syntax
Razor is not a programming language. It is a server-side markup language.
What is Razor?
Razor is a markup syntax that allows you to embed server-side code (Visual Basic and C#) in web pages.
When a web page is written to the browser, server-side code can create dynamic content. Before the server returns the page to the browser, it executes server-side code within the page when the page is loaded. Since this code runs on the server, it can perform complex tasks such as accessing databases.
Razor is based on ASP.NET and is designed for creating web applications. It has the capabilities of traditional ASP.NET tags but is easier to use and learn.
Razor Syntax
The syntax used by Razor is similar to PHP and ASP.
Razor:
<ul> @for (int i = 0; i < 10; i++) { <li>@i</li> } </ul>
PHP:
<ul> <?php for ($i = 0; $i < 10; $i++) { echo("<li>$i</li>"); } ?> </ul>
Web Forms (and Classic ASP):
<ul> <% for (int i = 0; i < 10; i++) { %> <li><% =i %></li> <% } %> </ul>
Razor Helpers
Razor helpers can be accessed via simple Razor code.
You can build your own helpers using Razor syntax, or use built-in ASP.NET helpers.
Below is a brief description of some important Razor helpers:
- Web Grid
- Web Graphics
- Google Analytics
- Facebook Integration
- Twitter Integration
- Sending Email
- Validation
Razor Programming Language
Razor supports both C# (C sharp) and VB (Visual Basic) at the same time.
- Previous Page WebPages Assistant
- Next Page Razor Syntax