ASP.NET MVC4 with Bootstrap 2.3.2

If you want to get Twitter Bootstrap 2.3.2 up and running with ASP.NET MVC4, there is a wonderful set of projects on NuGet for that. However, it’s not straight forward to get it installed. There are issues that have not been resolved due to the author’s time constraints (admittedly by him) in keeping up the NuGet project. Still, if you want to get an MVC4 Bootstrap 2.3.0 app going, this is a pretty good place to start inspite of the problems.

I have struggled to get it up and going and have noticed in my search for answers that others have as well. I have finally converged upon a sequence of steps that get it going. I’ve not found these all in one place, so, I’ve decided to document my approach here. I hope it works for you . . .

  1. In Visual Studio, create a new, empty MVC 4 application.
  2. Open the Library Package Manager console window and load the two Twitter Bootstrap MVC 4 and Sample packages
    1. “Tools | Library Package Manager | Package Manager Console”
    2. At the PM> prompt, type
         install-package twitter.bootstrap.mvc4 -Version 1.0.90
      and press [Enter] and wait for it to install.
    3. At the PM> prompt, type
         install-package twitter.bootstrap.mvc4.sample -Version 1.0.90
      and press [Enter] and wait for it to install
    4. Later versions have bugs that have not been fixed. 1.0.90 is a stable version
  3. Paths in the BootstrapBundleConfig are wrong and need to be fixed. Change it to something like this . . .

    bundles.Add(new StyleBundle(“~/content/css”).Include(
        “~/Content/bootstrap/bootstrap.css”,
        “~/Content/body.css”,
        “~/Content/bootstrap/bootstrap-responsive.css”,
        “~/Content/bootstrap-mvc-validation.css”
        ));

  4. The Bootstrap files need to be updated (the ones that come down in NuGet aren’t right). You’ll need to install it manually in your project.
    1. Get bootstrap 2.3.2 from here . . . click the big blue “Download Bootstrap” button.
    2. Open the download file, extract it and copy the css and js files over the existing ones in the \Content and \Scripts folders . . . watch out for the paths
  5. In the _BootstrapLayout.basic.cshtml, change the lines
            <link href=”@Styles.Url(“~/content/css”)” rel=”stylesheet”/>
    to
            @Styles.Render(“~/content/css”)

OR . . .

you can just download this project with all of the above and start from there.