ASP.NET MVC @RenderBody

时间:2014-01-20 10:21:10

标签: asp.net-mvc razor

我有以下布局文件:

 <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Radio Manager</title>
    <link rel="stylesheet" href="Content/Template/css/style.css" type="text/css" />
    <!--[if IE 9]>
        <link rel="stylesheet" media="screen" href="Content/Template/css/ie9.css"/>
    <![endif]-->
    <!--[if IE 8]>
        <link rel="stylesheet" media="screen" href="Content/Template/css/ie8.css"/>
    <![endif]-->
    <!--[if IE 7]>
        <link rel="stylesheet" media="screen" href="Content/Template/css/ie7.css"/>
    <![endif]-->
    <script type="text/javascript" src="Content/Template/js/plugins/jquery-1.7.min.js"></script>
    <script type="text/javascript" src="Content/Template/js/plugins/jquery.flot.min.js"></script>
    <script type="text/javascript" src="Content/Template/js/plugins/jquery.flot.resize.min.js"></script>
    <script type="text/javascript" src="Content/Template/js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
    <script type="text/javascript" src="Content/Template/js/custom/general.js"></script>
    <script type="text/javascript" src="Content/Template/js/custom/dashboard.js"></script>

    <!--[if lt IE 9]>
        <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
    <![endif]-->
    <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="Content/Template/js/plugins/excanvas.min.js"></script><![endif]-->
</head>
    @Html.Partial("_Header_top")

    <!-- START OF MAIN CONTENT -->
    <div class="mainwrapper">
    <div class="mainwrapperinner">
        @Html.Partial("_Menu_left")
        @RenderBody()

    </div><!--mainwrapperinner-->
</div><!--mainwrapper-->
<!-- END OF MAIN CONTENT -->

</html>

现在它给了我一个错误,即div不能嵌套在html标签中。

我认为问题在于renderBody辅助函数插入了body标签。

但我需要在两个div标签内呈现我的视图。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

您错过了<body></body>代码。移动head标记

下的<body></body>以外的所有标记