C # Main Razor syntax rules:
Razor code block by @{...} Surrounded
Inline expression starts at @
The code statement ends with a semicolon
Variables are declared by var keyword
Strings are surrounded by references.
C # code is case sensitive
C # files have the. cshtml extension.
Content block
@RenderPage () import content from a different file
Working with layout pages
@RenderBody ()
The content page must start with the layout directive
Prevent code leaks
In ASP. Files that begin with an underscore name cannot be browsed through the web
Hide sensitive information
In ASP. NET, the usual way to hide sensitive information is to store this information in a separate file called "_appstart".
Asp. NET provides three tools for working with folder paths: The ~ operator, the Server.MapPath method, and the Href method.
~ operator
Specify the virtual root directory in the programming code, use the ~ operator
The Server.MapPath method transforms the virtual path (/default.cshtml) into a physical path that the server can understand.
The href method transforms the path in the code into a path that the browser can understand.
Before Web startup: _appstart
Before each page: _pagestart