Razor Intro

http://www.w3schools.com/aspnet/razor_intro.asp

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:

<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 i = 0 to 10%>
<li><% =i %></li>
<% } %>
</ul> 

 

Razor Helpers

ASP.NET helpers are components that can be accessed by single lines of Razor code.

You can build your own helpers using Razor syntax, or use built-in ASP.NET helpers.

Below is a short description of some useful Razor helpers:

  • Web Grid
  • Web Graphics
  • Google Analytics
  • Facebook Integration
  • Twitter Integration
  • Sending Email
  • Validation

Razor Programming Languages

Razor supports both C# (C sharp) and VB (Visual Basic).

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(256)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2015-06-30 makeBackronym
2015-06-30 Regular Ball Super Ball
2014-06-30 winform中splitter的用法
2014-06-30 VS中 Winform查看窗体内控件之间的相互关系
点击右上角即可分享
微信分享提示