在我_Layout.cshtml
的body
元素的最后一行是:与布局网页上显示脚本奇怪的错误
@RenderSection("Scripts", required: false)
然而,当我跑我的应用程序,我得到异常:
The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Scripts".
奇怪够了,因为Scripts
不是必需的。然后,在我的登录页面,我注释掉以下行:
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
而且应用程序运行良好。这是不是因为jqueryval
包是空的,所以视图引擎认为Scripts
部分没有在_Layout.cshtml
中呈现?我的BundleConfig
包含有问题的脚本,它存在于我的Scripts
文件夹中,那么可能会出现什么问题?
我不能重现这一点。你碰巧有嵌套的布局页面(这可能会导致错误) –