not been rendered"~/Views/Shared/_Layout.cshtml": "Scripts".

简介: “/MvcMusicStoreV3”应用程序中的服务器错误。 使用模板创建的Controller, 运行Edit和Create会出现下面错误提示,而其它页面则不会。

“/MvcMusicStoreV3”应用程序中的服务器错误。

使用模板创建的Controller,

image

运行Edit和Create会出现下面错误提示,而其它页面则不会。

The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Scripts".

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Web.HttpException: The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Scripts".
源错误:

原因分析:

由参考文献知,由于开发环境默认给Edit和Create文件中添加了:

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

image

image

而在Share/_Layout.cshtml中没有进行声明引发的。

解决方案是在Share/_Layout.cshtml添加一个声明就可。

@RenderSection("scripts", required: false)

image

运行效果:

image

参考文献:

http://stackoverflow.com/questions/10971149/the-following-sections-have-been-defined-but-have-not-been-rendered-for-the-layo

image

相关文章
|
SQL 算法
【hacker的错误集】html5lib使用报错Couldn‘t find a tree builder with the features you requested: html5lib
分析得出:bs4的特征没有找到:找不到具有您请求功能的树生成器:html5lib。您需要安装解析器库吗?
424 0
【hacker的错误集】html5lib使用报错Couldn‘t find a tree builder with the features you requested: html5lib
|
5月前
|
存储 算法 数据处理
C++一分钟之-范围基础:views与ranges
【7月更文挑战第1天】C++20的Ranges库简化了集合操作,引入了Range(具有begin()和end()的对象)和View(延迟计算的Range)。常见问题包括混淆Range与Container、忽视View的延迟性和错误修改只读View。要避免错误,需理解Range概念、明确操作执行时机并检查View的可变性。代码示例展示了如何过滤并平方vector中的奇数,体现Range的使用。范围库带来了代码的简洁和效率,但理解其工作原理至关重要。
115 0
|
7月前
|
机器学习/深度学习 前端开发 安全
【Gradio】Could not create share link
【Gradio】Could not create share link
2530 6
App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW in
App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW in
126 0
|
前端开发 Android开发
React Native之提示Unable to load script from assets ‘index.android.bundle
React Native之提示Unable to load script from assets ‘index.android.bundle
125 0
- Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <script>, as t
vue.js报错如下: - Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as , as they will not be parsed.
5658 1