ASP.Net Razor

Introduction

If a web developer wants to embed server based code into a web page then the Razor is used. It is not a programming language , it is a server side markup language.

Razor provide a easy way to create dynamic web content very quickly.  At the time when the web page is called , server executes server based code within the web page before it  return back the page to the Web Browser. The complex tasks like fetching the data from database can be perform by code running on the server.

Razor is completely based on the ASP.Net and its main focus is on creating web applications.

Syntax

Razor

    <ol>

    @for(int a=27; a<90; a++){

    <li>@a</li>

     }

    <ol>

 

Razor helpers


ASP.Net provide some components that can be accessed by single line of razor code , these are the ASP.Net helpers.

A web Developer can build his/her own helper using Razor syntax and also he/she can use built-in ASP.Net helpers.

Some very useful helpers are :

  • Google Analytics
  • Web Graphics
  • Facebook Integration
  • Web Grid
  • Twitter integration
  • Validation


Razor supports C# and VB both the languages.