@RenderSection与@RenderBody

_LayoutMain:

<html>

  <head>

    @RenderSection("head")

  </head>

  <body>

    @RenderBody()

  </body>

</html>

_LayoutMainSub:

@{Layout=“~/Views/Shared/_LayoutMain.cshtml”}

@section head{<script type='text/javasctip'>alert('note')</script>}

<div>

  Welcome to xian

</div>

------------------------------------

问:如果,_LayoutMain引用后,整个_LayoutMainSub将加入到_LayoutMain的【@RenderBody】部分,那么【section head】部分的脚本是不是应该在【_LayoutMain】的body内。但是【_LayoutMainSub】中指明【@section head】应该是在【_LayoutMain】的【head】部分。到底结果是什么?原因又是什么?

猜:@section name 优先

posted @ 2014-02-16 12:44  李子康  阅读(2175)  评论(1编辑  收藏  举报