Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Scripts.Render("~/bundles/bootstrap") is throwing NullReferenceException

I am working on this ASP.NET MVC project. I did not do any changes to the _Layout.cshtml or BundleConfig.cs or Web.config. When I ran the project, it is showing the below exception:

System.NullReferenceException: 'Object reference not set to an instance of an object.' [External Code] ASP._Page_Views_Shared__Layout_cshtml.Execute() in _Layout.cshtml

I tried the minification method but still it failed. If it is possible to view, please check the photos below.

Can somebody help me resolve this issue, please?

Picture01

Picture02

Pciture03

like image 627
oybek Avatar asked Feb 15 '26 09:02

oybek


1 Answers

Replace the following:

bundles.Add(new ScriptBundle("~/bundles/mybundle").Include(
            "~/Scripts/...",
            "~/Scripts/..."));

with this:

bundles.Add(new Bundle("~/bundles/mybundle").Include(
            "~/Scripts/...",
            "~/Scripts/..."));
like image 122
Akanksha Avatar answered Feb 17 '26 22:02

Akanksha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!