Razor - C# and VB code syntax


  Translation results:

Razor is a markup syntax that allows you to embed server-based code (Visual Basic and C#) into web pages.

Server-based code creates dynamic web content as the web page is delivered to the browser. When a web page is requested, the server executes the server-based code in the page before returning the page to the browser. Run by 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 - C# and VB code syntaxsyntax

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

Razor - C# and VB code syntaxexample

<!-- Single statement block -->
@{ var myMessage ="Hello World"; }
<!-- Inline expression or variable -->
<p>The value of myMessage is: @myMessage</p> 
<!--Multi-statement block -->
@{
var greeting = "Welcome to our site!";
var weekDay = DateTime.Now.DayOfWeek;
var greetingMessage = greeting + " Here in Huston it is: " + weekDay;
}
<p>The greeting is: @greetingMessage</p>

Popular Recommendations

Home

Videos

Q&A