RAZOR
Razor is a view engine that supported in ASP.NET MVC.It helps to combine code and html in fluid manner. Its not a programming language itself, it is a simple-syntax view engine and was released as part of ASP.NET MVC 3. MVC uses view engine to find and display the views that are requesting from the controller.This view engine is responsible for creating HTML from the views.
There are many types of view engines.They are:
ASPX
Razor
Spark
NHaml
NDJango
Hasic
Brail
The view engine works between the view and the browser to provide HTML to the browser. ASPX View Engine/ WebForm engine is the default view engine for the ASP.NET MVC that comes with ASP.NET MVC from the start (MVC 1.0) . The Razor view engine allows us to write mix of HTML and the server side code using C# or Visual Basic . Razor view with visual basic syntax has .vbhtml file extension and C# syntax has .cshtml file extension.
Some of the Razor Syntax Rules For C# are given below:
Razor code blocks must enclosed in @{ … }-Here “@” is character that tells beginning of Razor syntax.
Razor view engine uses @ character to start inline expressions (variables and functions)
Code statements end with a semicolon
Variables are declared using the keyword ‘var’
Strings are wriiten inside quotation marks
C# code is case sensitive
C# files have the file extension .cshtml
Razor syntax has following Characteristics:
Compact: The Razor syntax is very compact, which helps you to minimize number of characters and keystrokes required to write a code.
Easy to Learn: Razor syntax is easy to learn where you can use language C# or Visual Basic.
Intellisense: Razor syntax supports statement completion within Visual Studio.