0

カスタム領域から _layout ファイルで定義されているセクションをレンダリングしようとしています。

私の地域では、ルート サイトの _layout を指す _ViewStart があります。

使用しようとしているセクションは head タグにありますが、私の地域では body に配置されています。

ルート レベルでレンダリングされるページは正常に動作します。

〜/Views/Shared/_Layout.cshtml

<head>

    @RenderSection("header", true)
</head>
<body>
 ....
</body>

~/Areas/UserMedia/Views/_ViewStart.cshtml

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

~/Areas/UserMedia/Views/ManageProjectMedia.cshtml

@{
    ViewBag.Title = "ManageProjectMedia";
}

@section header{
{
<!-- scripts and styles -->
}

<div>
 ... page content
</div>
4

1 に答える 1

2

あなたの質問で、パスがであるコードサンプルを指摘し、~/Views/_layout.cshtmlお住まいの地域の_ViewStart.cshtmlファイルに次のコードがあります。

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

ここで7つの違いが見つかると確信しています:)

7つの違いは冗談でしたが、とにかく。あなた_Layout.cshtmlは下に座っていますが、あなたは下にあるものを~/Views/参照しています。_Layout.cshtml~/Views/Shared/

于 2011-10-24T14:31:23.553 に答える