ASP.NET Razor - Markup

Razor is not a programming language. 

It's 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 on the fly, while a web page is written to the browser. When a web page is called, the server executes the server-based code inside the page before it returns the page to the browser. By running on the server, the code can perform complex tasks, like accessing databases.

Razor is based on ASP.NET, and designed for creating web applications. It has the power of traditional ASP.NET markup, but it is easier to use, and easier to learn.

Razor Syntax
Razor uses a syntax very similar to PHP and Classic ASP.

Razor Code:

<ul>
@for (int i = 0; i < 10; i++) {
<li>@i</li>
}
</ul>

PHP Code:

<ul>
<?php
for ($i = 0; $i < 10; $i++) {
echo("<li>$i</li>");
}
?>
</ul>

Classic ASP Code:

<ul>
<%for i = 0 to 10%>
<li><%=i%></li>
<%next%>
</ul>

References:
asp.net
docs.asp.net
live.asp.net
https://en.wikipedia.org/wiki/ASP.NET_Razor
Create a Razor Pages web app with ASP.NET Core
Razor syntax reference for ASP.NET Core

Comments

Popular posts from this blog

Insert data into a database table using ASP.Net, C# and Microsoft SQL Server Stored Procedure

CRUD Operation - ASP.NET Core MVC with EF Core

Forward to 404 page for all missing URL - ASP.NET