Razor front, must be with the front of the gap, that is, the space, after the need to be coherent, otherwise add parentheses
1, when outputting a single variable in the page, simply precede the C # statement with the @ symbol.
For example
1 <p>2 present moment: @DateTime. Now3 </p>
2, if you want to output a paragraph containing a blank word or word operation results, you must add a parenthesis before and after
1 <p>2 member name: @ (viewbag.isenabled?" ) enabled " " Deactivate " )3 </p>
3, to execute multiple lines of C # code on a page, you must add a curly brace (but conform to the C # code specification and each line plus; number).
<p> @{ int i=2; int 4 ; } </p>
4, in order to insert HTML or other text content in the multiline C#razor syntax, you must add "@:" at the top of each line, plus the "@:" symbol in this line of code, plus other razor variables
@{ var name=" Zhang San "; @: Hello, I'm @name}
It should be considered as a C # statement sentence to enter plain text directly in razor, want to enter a lot of text, if all add @: It is inconvenient, you can
1 @{2 @* just add the HTML tag. *@3 <span> Stephensteffen going to leave </span> 4 }
5, razor in the note can be used @*code*@;
6, to output the @ symbol,
1 @@ 你好
Output
@ Hello
Razor view basic syntax in MVC (1)