why my vs mvc project doesnt accept bootstrap 4 or higher?

Kokombads Bleh Bleh 26 Reputation points

So I was following a tutorial on MVC, the tutor changed the default bootstrap theme into a bootstrap 4 lumen theme from bootswatch. I did the same but the theme, button, and navbars didnt show as it was in the tutorial. If I put a boostrap 3 theme, it goes a little fine (not the same as the preview the bootswatch site shows but it is better than what happens in bootstrap 4 or higher).
So I tried to fix this by upgrading the bootsrap from nuget into bootstrap 4, still the same. then I tried upgrading to bootstrap 5.1, the same result.
So what's wrong with this?

here is a screen shot of what happen if I use the bootswatch's bootsrap 5 (left) vs the bootstrap 3 version


here is my bundleconfig (there was an error in the 'bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(' and another tutorial told that to fix this, I should rewrite 'new ScriptBundle' into 'new Bundle')

public class BundleConfig  
        // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862  
        public static void RegisterBundles(BundleCollection bundles)  
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(  
            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(  
            // Use the development version of Modernizr to develop with and learn from. Then, when you're  
            // ready for production, use the build tool at https://modernizr.com to pick only the tests you need.  
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(  
            //bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(  
            //          "~/Scripts/bootstrap.js"));  
            bundles.Add(new Bundle("~/bundles/bootstrap").Include(  
            bundles.Add(new StyleBundle("~/Content/css").Include(  
A set of technologies in the .NET Framework for building web applications and XML web services.
3,361 questions
{count} votes

Accepted answer
  1. Yijing Sun-MSFT 7,071 Reputation points

    Hi @Kokombads Bleh Bleh ,
    Bootstrap3 with Bootstrap4 and Bootstrap5 have many css changes.So you need to change your _layout elements. You could use "nav-link" class to replace with @azzedinehtmlsql .ActionLink. It fits Bootstrap4 and Bootstrap5.

        <meta charset="utf-8" />  
        <meta name="viewport" content="width=device-width, initial-scale=1.0">  
        <title>@ViewBag.Title - My ASP.NET Application</title>  
       <nav c lass="navbar navbar-expand-sm navbar-dark fixed-top" s tyle="background-color:gray">  
           <div c lass="container">  
                <div c lass="navbar-header">  
                    <button c lass="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">  
                        <span c lass="navbar-toggler-icon"></span>  
                    <a c lass="navbar-brand" href="#">Application name</a>  
                <div c lass="collapse navbar-collapse" id="navbarColor01">  
                    <ul c lass="nav navbar-nav">  
                        <li c lass="nav-item active">  
                            <a c lass="nav-link" href="#">Home</a>  
                        <li c lass="nav-item">  
                            <a c lass="nav-link" href="#">About</a>  
                        <li c lass="nav-item">  
                            <a c lass="nav-link" href="#">Contact</a>  
                        <li c lass="nav-item">  
                            <a c lass="nav-link" href="#">Login</a>  
      <div c lass="container body-content">  
            <hr />  
                <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>  
        @RenderSection("scripts", required: false)  

    Best regards,
    Yijing Sun

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful