Twitter bootstrap 使用ASP.NET MVC 4设置TwitterBootstrap

Twitter bootstrap 使用ASP.NET MVC 4设置TwitterBootstrap,twitter-bootstrap,asp.net-mvc-4,Twitter Bootstrap,Asp.net Mvc 4,这就是我到目前为止所做的: 1) 在VS2012中创建新的ASP.NET MVC 4项目 2) 选择“internet应用程序”模板(包括成员资格和实体框架) 3) 测试一下,效果很好 4) 使用包管理器,运行: > Install-Package twitter.bootstrap.mvc4 > Install-Package twitter.bootstrap.mvc4.sample 5) 在“_ViewStart.cshtml”中,更改 到 不幸的是,当我现在运行它时,出现以

这就是我到目前为止所做的:

1) 在VS2012中创建新的ASP.NET MVC 4项目

2) 选择“internet应用程序”模板(包括成员资格和实体框架)

3) 测试一下,效果很好

4) 使用包管理器,运行:

> Install-Package twitter.bootstrap.mvc4
> Install-Package twitter.bootstrap.mvc4.sample
5) 在“_ViewStart.cshtml”中,更改

不幸的是,当我现在运行它时,出现以下错误:

The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_BootstrapLayout.basic.cshtml": "featured".
我是ASP.NET新手,不太清楚发生了什么以及为什么会发生这种情况。有什么想法吗


第二个问题是,一旦我解决了这个问题,我如何从安装模板?我似乎找不到任何关于如何使用ASP.NET的说明。

在您的Home/index.cshtml中定义了引导布局中没有的部分

要么将它们添加到新布局中(请参见Shared/_layout.cshtml了解如何查找被称为特色的内容),要么从index.cshtml中删除它们


关于家庭作业,请查看如何在ASP.MVC中定义部分这对于原始海报来说可能太晚了,但我认为更好的解决方案是从一个空的MVC4项目开始。这样,您就不必删除任何内容

1) Start with an empty ASP.NET MVC 4 project.
2) Using the package manager, run:

    install-package twitter.bootstrap.mvc4
    install-package twitter.bootstrap.mvc4.sample
这在我的VS2012上构建并运行良好


在我看来,这似乎是安装示例代码的原始方式。

\u BootstrapLayout.basic.cshtml中,验证您是否在@RenderSection中具有“特色”:

<head>
    <meta charset="utf-8">
    <title>@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="@Styles.Url("~/content/css")" rel="stylesheet"/>
    @RenderSection("featured", required: false)
    @Html.Partial("_html5shiv")
</head>

@视图包。标题
@渲染部分(“特色”,必填项:false)
@Html.Partial(“_html5shiv”)

第二个问题应该是另一个问题。简单的回答是,你不能直接把它放进去,因为它是为使用引导程序而设计的,而不是ASP MVC。您需要做大量的工作才能使这些模板正常工作。作为一个新问题提问,您可能会得到一些更好的建议。一般性建议:您可能会发现一个有用的库,我必须更改\Views\Home\Inbox.cshtml和comment@section-featured blocks引导“开箱即用”解决方案需要更多的“开箱即用”解决方案,显然理解小节是有帮助的,但是修复应该有效的代码不需要做家庭作业,Hanzolo请参阅BillH的答案,了解您想要的解决方案。查看我的答案,了解它为什么会中断,并完成如何使用ASP.MVC中的部分来理解抛出的错误的家庭作业。我的答案是一个完整而准确的答案,它解决了这个问题,并且不要求世界以某种方式存在。
1) Start with an empty ASP.NET MVC 4 project.
2) Using the package manager, run:

    install-package twitter.bootstrap.mvc4
    install-package twitter.bootstrap.mvc4.sample
<head>
    <meta charset="utf-8">
    <title>@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="@Styles.Url("~/content/css")" rel="stylesheet"/>
    @RenderSection("featured", required: false)
    @Html.Partial("_html5shiv")
</head>