Bootstrap with ASP.NET MVC 4 – Sample Source Code

This is the continuation of the article Bootstrap with ASP.NET MVC 4 – Step by Step – Without NuGet Package. Here is the sample source code for the files _Layout.cshtml, Index.cshtml and HomeContainer.cs, which I’ve modified and created for the step by step instruction.

Use this code and follow the step by step instructions explained in Bootstrap with ASP.NET MVC 4 – Step by Step – Without NuGet Package.

Sample Source Code of BundleConfig.cs: (Download BundleConfig.cs)

using System.Web;
using System.Web.Optimization;

namespace MyTecBits_Bootstrap_MVC
    public class BundleConfig

        public static void RegisterBundles(BundleCollection bundles)

            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(

            bundles.Add(new ScriptBundle("~/bundles/bootstrapjs").Include(

            bundles.Add(new StyleBundle("~/Content/bootstrapcss").Include(

Sample Source Code of _Layout.cshtml: (Download _Layout.cshtml)

<!--<span class="hiddenSpellError" pre=""-->DOCTYPE html>
 <meta charset="utf-8" />
 <meta name="viewport" content="width=device-width" />
 <div class="container-fluid">
 <div class="row-fluid">
 <div class="span3">
 <div class="well sidebar-nav">
 <ul class="nav nav-list">
 <li class="nav-header">1st Navigation Header</li>
 <li>@Html.ActionLink("Link 1","../")</li>
 <li>@Html.ActionLink("Link 2","../")</li>
 <li>@Html.ActionLink("Link 3","../")</li>
 <li>@Html.ActionLink("Link 4","../")</li>
 <li class="nav-header">2nd Navigation Header</li>
 <li>@Html.ActionLink("Link AA","../")</li>
 <li>@Html.ActionLink("Link BB","../")</li>
 <li>@Html.ActionLink("Link CC","../")</li>
 <div class="span9">
 @RenderSection("featured", required: false)
 <div class="row-fluid">

Sample Source Code of view file Index.cshtml: (Download Index.cshtml)

 ViewBag.Title = "Index View - My tec Bits";
@section featured {
 <div class="hero-unit">
 <h1>Welcome to</h1>
 <p>This is my first ASP.NET MVC4 with Bootstrap website........</p>
Some content goes here........
@Html.ActionLink("Home >>","../", null,new { @class="btn btn-primary btn-large" })

Sample Source Code of Controller File HomeController.cs: (Download HomeController.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyTecBits_Bootstrap_MVC.Controllers
 public class HomeController : Controller
 // GET: /Home/

public ActionResult Index()
 return View();


Instructions for using the above sample source code is explained in  Bootstrap with ASP.NET MVC 4 – Step by Step – Without NuGet Package.

Output of the sample code:


6 thoughts on “Bootstrap with ASP.NET MVC 4 – Sample Source Code”

    • I found the solution. Some posts were suggesting putting
      at the top but that didn’t actually fix it. The thing that fixed it was:

      So here is the top of the final version of my _Layout.cshtml:



Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.