MVC 5 @Scripts.Render("~/bundles/bootstrap") error 'Object reference not set to an instance of an object.'

Bentinio picture Bentinio · Jun 16, 2021 · Viewed 7.5k times · Source

_Layout.cshtml file fails when attempting to render the bootstrap 5 script bundle (works for earlier versions of bootstrap)

Bundle.Config File

_Layout Debugging

Scripts Folder

Answer

Manoj Salvi picture Manoj Salvi · Aug 9, 2021

Try changing "new ScriptBundle" to "new Bundle" in your "RegisterBundles" within BundleConfig:

bundles.Add(new Bundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap.js"));