ASP.NET Razor - Markup
Razor is not a programming language. It is a server-side markup language.
What is Razor?
Razor is a markup syntax that lets you embed server-based code (Visual Basic and C#) into web pages.
Server-based code can create dynamic web content when the page is delivered to the browser. When a page is requested, the server executes the server-based code in the page before returning it to the browser. By running on the server, the code can perform complex tasks, such as accessing a database.
Razor is based on ASP.NET and is designed for creating web applications. It has the functionality of traditional ASP.NET but is easier to use and easier to learn.
Razor syntax
Razor uses a syntax similar to PHP and classic ASP.
Razor:
- @i
@for (int i = 0; i < 10; i++) {
}
PHP:
-
$i"); } ?>
Web Forms (classic ASP):
- <% =i %>
<% for (int i = 0; i < 10; i++) { %>
<% } %>
Razor Helpers
ASP.NET helpers are components accessible with just a few lines of simple Razor code.
You can build your own helpers using Razor syntax, or use the built-in ASP.NET helpers.
Below are brief descriptions of some useful Razor helpers:
- Web Grid (Web Grid)
- Web Graphics (Web Graphics)
- Google Analytics (Google Analytics)
- Facebook Integration (Facebook Integration)
- Twitter Integration (Twitter Integration)
- Sending Email (Sending Email)
- Validation (Validation)
Razor Programming Language
Razor supports C# (C sharp) and VB (Visual Basic).