Razor syntax role for C#
- Variable and functions with inline property must start with the @
- Variables are declared with the var keyword
- Razor block having C# code always enclosed with in @{….}
- Code statements always end with semicolon
- C# file will have the extention “cshtml”
Working of Razor code
Razor code syntax completely based on ASP.Net framework. It is part of the Microsoft.NET Framework that is specially designed for creating web applications. The most important thing about the Razor is that the syntax gives developer all the power of ASP.NET, but it use a simplified syntax .
Razor is very simple programming syntax for embedding server code in web pages. When a web page having razor code describeed as a html page we found two type of content
- Normal HTML Content
- Razor Code.
It is the Razor code that runs first whenever the sever reads the page. After this only the server sends the HTML page to webbrowser. Sometimes there may be the condition that code that is executed on the server can perform tasks that cannot be perform in the web browser.
ASP.NET web pages that contain Razor code have the special file extension cshtml (Razor using C#) .