下面的部分已确定,但尚未呈现的页面布局"〜/查看/共享/ _Layout.cshtml":"脚本" [英] The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Scripts"

查看:797
本文介绍了下面的部分已确定,但尚未呈现的页面布局"〜/查看/共享/ _Layout.cshtml":"脚本"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的ASP MVC和href=\"http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4\">http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4

I'm new to ASP MVC and utilizing the Intro to ASP MVC 4 Beta tutorial http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4

我遇到了,我似乎无法找到一个答案,也没有我有很多编程经验,所以我不知道在哪里甚至开始固定在本教程这样的一个举动错误。我AP preciate任何帮助,您可以提供。

I'm encountering an error that I can't seem to find an answer to nor do I have much programming experience so I don't know where to even start to fix this an move on with the tutorial. I appreciate any help you can provide.

我在从控制器部分访问您的模型数据,当我试图创造一个电影作为本教程的一部分,我得到这个错误,我点击链接创建新的关于我得到的以下错误

I'm in the Accessing Your Model's Data from a Controller section and I am getting this error when I attempt to creat a Movie as a part of the tutorial, I click on the the link "Create New" and I get the following error

下面的路段已确定,但尚未呈现的页面布局>〜/查看/共享/ _Layout.cshtml:脚本

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

而不是使用Visual Studio EX preSS,我选择下载的Visual Studio 2012 RC(不知道这将是我的问题的根本原因。

Rather than use Visual Studio express, I opted to download Visual Studio 2012 RC (not sure if that would be the root cause of my issue.

我意识到你可能需要我,包括code来回答这个,但我不知道什么code,甚至包括。请指教一下code你需要我,包括如果有,我会很乐意将它添加到我的问题。

I realize you may require me to include code to answer this but I'm not sure what code to even include. Please advise what code you need me to include if any and I will be happy to add it to my question.

感谢您,

推荐答案

这意味着你已经定义了你的主人Layout.cshtml一节,但你还没有为你的观点,即部分东西。

It means that you have defined a section in your master Layout.cshtml, but you have not included anything for that section in your View.

如果您有_Layout.cshtml是这样的:

If your _Layout.cshtml has something like this:

@RenderSection("scripts")

然后,所有使用该浏览布局必须包含一个 @section 具有相同名称(即使该部分的内容是空的)

Then all Views that use that Layout must include a @section with the same name (even if the contents of the section are empty):

@{
    ViewBag.Title = "Title";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section scripts{
    // Add something here
}

作为替代方案,
你可以设定要求为false,那么你将不会被要求增加部分在每个视图,

As an alternative, you can set required to false, then you won't be required to add the section in every View,

@RenderSection("scripts", required: false)

或者,你也可以在如果块包裹 @RenderSection

@if (IsSectionDefined("scripts"))
{
    RenderSection("scripts");
}

这篇关于下面的部分已确定,但尚未呈现的页面布局"〜/查看/共享/ _Layout.cshtml":"脚本"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆