An MVC app broke after we updated all the NuGet packages. After trying everything I created a new MVC app, updated the NuGet packages and the basic navbar...
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Application name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li><a href="/Home/About">About</a></li>
<li><a href="/Home/Contact">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/Account/Register" id="registerLink">Register</a></li>
<li><a href="/Account/Login" id="loginLink">Log in</a></li>
</ul>
</div>
</div>
</div>
... looks like this ...
...and clicking the icon...
Any ideas what could be causing this?
Have tried manually adding Bootstrap.css and Bootstrap.js to _Layout.vbhtml, but no difference
Thank you
What's causing the issue is that Bootstrap 4 can't recognize classes from Bootstrap 3, and Bootstrap 3 is what ASP .NET uses at this point. Just downgrade to Bootstrap 3.3.7 from NuGet and you'll be good to go.
Thanks Jon! I tried the code and works well.
After adding the HTML Attribute to the Action Link in lists, the Index action was red - somehow MVC couldn't find the Index Method. I added "null" after the "Home" Controller and it went away. Posting it here , so someone can benefit from it.
@Html.ActionLink("Home","Index", "Home",null, new { @class = "nav-link" }) @Html.ActionLink("About", "About", "Home",null, new { @class = "nav-link" }) @Html.ActionLink("Contact", "Contact", "Home",null, new { @class = "nav-link" })
Thanks, Drac. Great answer.
For anyone that wants the Razor code, here's mine:
[EDIT: Code includes changes suggested by @Suhani and @Sagi / @Doug Dekker
This is _Layout.cshtml
and this is _LoginPartial.cshtml
Finally, I managed my HTML and yours. There're a lot of changes in Bootstrap 4 in compare to version 3. Regarding your markup, you have to change:
All changes below. Tested here.
All of the above answers amazing.
My solution is temporary and shorter: Uninstall bootstrap and reinstall older version.
In Package-manager console: To uninstall, type this: uninstall-package bootstrap
once done, reinstall the old version which worked, eg: install-package bootstrap -Version 3.3.7
Just uninstall the updated modules. I'm pretty sure it's Antlr Package and Bootstrap. Downgrade them to 3.4.1 and 3.3.0 respectively. This helped my issue.