Unable to use Bootstrap though it's added to my project

Viewed 447

I feel so stupid putting this question out there...

I'm using Visual Studio 2019. I used the NuGet Packager Manager to add Bootstrap 4.5 to my .Net Core 3.1 Web project. When I did so, it added the following:

wwwroot
    css
        bootstrap.css
        bootstrap.grid.css
        bootstrap-reboot.css
    js
        bootstrap.js

However, the folder and the files all have a blue arrow on them, signifying that they are links. When I look in the project file, I see:

<ItemGroup>
    <Content Update="C:\Users\SomeGuy\.nuget\packages\bootstrap\4.5.0\contentFiles\any\any\wwwroot\css\bootstrap.css">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
</ItemGroup>

Whenever I try to add a link to the css file in my _Layout.cshtml file, it doesn't show in the autocomplete.

Is there something I'm supposed to do to the NuGet package? Or to the wwwroot folder? Or is there a special way I'm supposed to access the css/js file? I've done some googling but I don't see anything that reference it. Any help is greatly appreciated. Thanks.

1 Answers

There isn't any special way to add the bootstrap links. They are just added as a link in your _Layout.cshtml file.

In the <head> section add a link to the css file:

<link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.css" />

At the end of the <body> tag add a link to the javascript file:

<script src="~/lib/bootstrap/js/bootstrap.js"></script>

You can use the minified version in production this way:

<environment include="Development">
    <link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.css" />
</environment>
<environment exclude="Development">
    <link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.min.css" />
</environment>

Related