ASP.Net MVC 5 Template: Broken Navbar after Update

Last week I run intro an annoying little problem with the ASP.Net MVC 5 template. I created a new MVC web application for .Net 4.8 and after updating the packages it looked like this:

The template has a broken navigation bar

The most visible error of the design is the missing navigation bar, but there are additional problems that will pop up if you continue to build your application. It took me a while to figure out what the source of this problem is. As it turns out, the Visual Studio template still uses Bootstrap 3 and a package update in NuGet installs version 4. Bootstrap 4 was a major rewrite and navbar was one of parts that had breaking changes.

 

The quick fix

We can fix this problem by installing version 3.4.1 of the Bootstrap NuGet package:

Install version 3.4.1

If we now run the application, the navbar is back and everything works as expected:

With Bootstrap 3 everything works

Downgrading to Bootstrap 3 is a fast solution for demo applications. Be aware that Bootstrap 3 is no longer supported.

 

The better and durable fix

If you build an application for production, downgrading to an unsupported version is a bad idea. Instead, upgrade the template to Bootstrap 4 or Bootstrap 5. That takes more time, but if you do that right after Create a new project you only need to update a few pages.

1 thought on “ASP.Net MVC 5 Template: Broken Navbar after Update”

  1. This happened to me with Bootstrap 5. It work fine for a couple of weeks. Then “broke”. I have no idea what changed?

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.