Click here to Skip to main content
15,884,298 members
Articles / Programming Languages / C# 5.0
Tip/Trick

ASP.NET MVC 5 - Bootstrap 3.0 in 3 Steps

Rate me:
Please Sign up or sign in to vote.
4.25/5 (3 votes)
3 Oct 2014CPOL2 min read 91.5K   16   3
This tip walks you through the steps for creating a ASP.NET MVC 5 Web Application using Bootstrap as template for layout.

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

Introduction

This tip walks you through the steps for creating a ASP.NET MVC 5 Web Application using Bootstrap as template for layout.

STEP 1 - Create ASP.NET Web Application

  • Open Visual Studio 2013 and create a new project of type ASP.NET Web Application.
  • On this project, I create a solution called MVCBootstrap.

Image 1

  • Press OK, and a new screen will appear, with several options of template to use on our project.
  • Select the option MVC.

Image 2

STEP 2 - Upgrade Version if Necessary

You can verify the version of bootstrap on two ways.

First one, accessing the files on Content or Scripts folder. If open for example the file Bootstrap.css, we can check that the version of bootstrap is the 3.0.0.

Image 3

Another way to verify the bootstrap version is to check the installed NuGet package.

  • Right click the solution and select Manage NuGet packages for solution.. option.
  • In the Manage NuGet screen, select Installed Packages section.
  • Then select the bootstrap package in the center pane to see the version details.

As you see, the version is 3.0.0.

Image 4

STEP 3 - Change Layout

The default bootstrap template used in Visual Studio 2013 is Jumbotron. Jumpotron’s original source code is available here in bootstrap website.

On this sample, we will change this template to the Justified-Nav one. So for that, do the next steps:

  • Add the style sheet justified-nav.css to the Content folder

Image 5

  • Open the BundleConfig.cs file under the App_Start folder.
  • Add the justified-nav.css to the “~/Content/css” style bundle.

Image 6

  • Now, open the layout file _Layout.cshtml in the Shared folder under Views Folder
  • Remove the section within the div tag with class=”navbar navbar-inverse navbar-fixed-top

Image 7

  • Open the Index.cshtml file in the Home folder under Views
  • Change the class col-md-4 to col-lg-4
  • Now the sample is ready.

This is the sample created with solution:

Image 8

This is the sample after our changes:

Image 9

Image 10

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Devscope
Portugal Portugal
I am João Sousa, and since i finish my degree I’m working in software development using Microsoft technologies.

I was awarded

Microsoft Most Valuable Professional (MVP) 2015 – .Net

My profissional profile:

Azure Developer
.NET Developer

My Certifications:

MCTS - .NET Framework - Application Development Foundation
MCTS - .NET Framework 2.0 - Windows-based Client Development
MCTS - .NET Framework 3.5 ADO.NET Applications
MCTS - .NET Framework 3.5 ASP.NET Applications
MCSD - Programming in HTML5 with JavaScript and CSS3
MCSD - Developing ASP.NET MVC 4 Web Applications
MCSD - Developing Windows Azure and Web Services
MCSA Office 365 - Managing Office 365 Identities and Requirements
MCSA Office 365 - Enabling Office 365 Services
MCSD - Implementing Microsoft Azure Infrastructure Solutions

Comments and Discussions

 
QuestionTheme doesn't match Pin
HankAnzis6-Aug-15 4:55
HankAnzis6-Aug-15 4:55 
SuggestionNice tip! Pin
Debabrata_Das17-Dec-14 20:58
professionalDebabrata_Das17-Dec-14 20:58 
This would be even better if you could upload better images (screen-shots) which are readable. Smile | :)
Regards,
DD

GeneralGood One Pin
Shemeemsha (ഷെമീംഷ)3-Oct-14 17:51
Shemeemsha (ഷെമീംഷ)3-Oct-14 17:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.