Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up TwitterBootstrap with ASP.NET MVC 4

This is what I have done so far:

1) create new ASP.NET MVC 4 project in VS2012.

2) select the "internet application" template (which includes membership and entity framework)

3) test it, it works fine

4) using the package manager, run:

> Install-Package twitter.bootstrap.mvc4
> Install-Package twitter.bootstrap.mvc4.sample

5) in "_ViewStart.cshtml", change

Layout = "~/Views/Shared/_Layout.cshtml" 

to

Layout = "~/Views/Shared/_BootstrapLayout.basic.cshtml"

Unfortunately, when I run it now, I get the following error:

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

I'm new to ASP.NET and am not really sure what's going on and why this is happening. Any ideas?

As a second question, once I get this fixed, how can I install a template from http://wrapbootstrap.com? I can't seem to find any instructions for how to do it with ASP.NET.

like image 437
Jordan Avatar asked Jan 14 '13 21:01

Jordan


3 Answers

in your Home/index.cshtml there are sections defined that aren't in the bootstrap layout.

either add them to the new layout (see Shared/_Layout.cshtml for how, you're looking for something called featured) or delete them from the index.cshtml.

For homework look up how to define sections in ASP.MVC

like image 134
Peter Avatar answered Nov 09 '22 04:11

Peter


This is probably too late for the original poster, but I think a better solution is to start with an Empty MVC 4 project. That way, you don't have to delete anything.

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

This builds and runs fine on my VS2012.

It seems to me that this was the original way the sample code was intended to be installed.

like image 7
BillH Avatar answered Nov 09 '22 03:11

BillH


In the _BootstrapLayout.basic.cshtml verify that you have "featured" in the @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>
like image 4
Alex_Sotam Avatar answered Nov 09 '22 03:11

Alex_Sotam