Search code examples
bootstrap-4asp.net-core-mvcvisual-studio-mac

Add bootstrap to ASP.NET Core in Visual Studio on Mac OS


I want to add bootstrap 4 to my asp.net core 2.2 on my Mac OS device. I have added it by Nuget but it doesn't seem to work.

I also do not have manage client-side library as well as manage Bower packages option. VS on Mac is different from on Windows so I have some problems.


Solution

  • You can add Manually without Nuget. Just Copy bootstrap all CSS and js file into your .net core project in Following Directory wwwroot (you can find it in root)

    And then put CSS and js links in ~/view/shared/_Layout.cshtml Like This

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

    And end of the page before

    </body>

    tag you can put jquery and bootstrap js like this

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

    that is not required to add CSS and js in

    Layout.cshtml

    you can add this js and css on any page but Layout.cshtl is root page so that bootstrap will apply globally on your site