DEV Community

Hòa Nguyễn Coder
Hòa Nguyễn Coder

Posted on

ASP.NET MVC 5 Install Bootstrap

Continue with the previous share, Today I will shared way install Bootstrap in ASP.NET MVC5, I using Visual Studio 2019
You can see again, The article previous

Setup Bootstrap 3.3.1 trong ASP.NET MVC 5
Click right Project -> Manager NuGet Packages -> you click icon setting configuration, add package source
https://api.nuget.org/v3/index.json
ASP.NET MVC 5 Install Bootstrap -  hoanguyenit.com
Continue! add package source
ASP.NET MVC 5 Install Bootstrap -  hoanguyenit.com
You search keyword "bootstrap" after then install
ASP.NET MVC 5 Install Bootstrap -  hoanguyenit.com
After when you install bootstrap success! you can see bootstrap in project
ASP.NET MVC 5 Install Bootstrap -  hoanguyenit.com

Okay, install success! you can use bootstrap in Layout file of Views/Shared/_LayoutHome.cshtml directory, note you add css,javascript to file

<link rel="stylesheet" href="~/Content/bootstrap.min.css" />
<script src="~/Scripts/jquery-3.3.1.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
Enter fullscreen mode Exit fullscreen mode

Example:Views/Shared/_LayoutHome.cshtml

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link rel="stylesheet" href="~/Content/bootstrap.min.css" />
    <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
</head>
<body>
    <div>
        @RenderBody()
    </div>
</body>

</html>
Enter fullscreen mode Exit fullscreen mode

Views/Home/Index.cshtml

<div class="container">
    <div class="row">

        <div class="col-md-12">
            <h2>@ViewBag.title</h2>
            <a href="https://hoanguyenit.com" class="btn btn-success">https://hoanguyenit.com</a>
        </div>
    </div>
</div>
Enter fullscreen mode Exit fullscreen mode

Ok, we install bootstrap in ASP.NET MVC 5 success!!

Post:ASP.NET MVC 5 Install Bootstrap

Top comments (0)