Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12444639
  • 博文数量: 1293
  • 博客积分: 13501
  • 博客等级: 上将
  • 技术积分: 17974
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 18:11
文章分类

全部博文(1293)

文章存档

2019年(1)

2018年(1)

2016年(118)

2015年(257)

2014年(128)

2013年(222)

2012年(229)

2011年(337)

分类: C#/.net

2015-08-03 17:32:18

“/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

阅读(4423) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~