Answers:
您可以使用@:
转义:
@if(Model.foo)
{
@:Hello World
}
或<text>
响应中未输出的特殊标签:
@if(Model.foo)
{
<text>Hello World</text>
}
@if(Model.foo)
{
@:Hello World
}
上面的答案很棒。我将包含指向Scott Guthrie的文章的链接,因为它显示了更多示例和解释。
https://weblogs.asp.net/scottgu/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax
@if (p.UnitsInStock == 0 {
<text>
Donec in ante vitae purus consequat laoreet ut elementum
purus. Ut ut tempus nulla, quis ultrices est. Integer
pharetra ante in lectus porta, a lacinia ex faucibus.
Aliquam magna risus, pretium vel neque at, laoreet
ultrices lectus. Morbi posuere luctus risus. Nullam
tincidunt massa egestas nunc tempor scelerisque.
</text>
}
@if (p.UnitsInStock == 0 {
@: Line 1
@: Line 2
@: Line 3
}