Razor 视图引擎是 ASP.NET MVC 3 开始扩展的内容,并且也是默认视图引擎。

       Razor 通过理解标记的结构来实现代码和标记之间尽可能顺畅的转换。下面的例子演示了一个包含少量视图逻辑的简单 Razor 视图:

@{
    // this is a block of code. For demonstration purposes,
    // we'll create a "model" inline.
    var items = new string[] { "one", "two", "three" };
}
<html>
<head><title>Sample View</title></head>
<body>
    <h1>Listing @items.Length items.</h1>
    <ul>
        @foreach (var item in items)
        {
            <li>The item name is @item.</li>
        }
    </ul>
</body>
</html>

相关文章:

  • 2022-02-07
  • 2021-04-13
  • 2021-09-18
  • 2021-08-10
  • 2021-06-20
  • 2021-06-26
猜你喜欢
  • 2022-03-02
  • 2021-09-05
  • 2022-12-23
  • 2021-09-16
  • 2021-07-08
  • 2021-06-11
相关资源
相似解决方案