ASP .NET
[ASP .NET] @Scripts.Render("~/bundles/bootstrap") NullReferenceException
코딩하는 박줄기
2021. 8. 31. 22:00
728x90
반응형
VS2019 | ASP.NET | MVC 프로젝트에 Bootstrap v5.1를 추가 할 때, NullReferenceException이 발생했습니다.
System.NullReferenceException: 개체 참조가 개체의 인스턴스로 설정되지 않았습니다.
에러가 발생하는 해당 라인입니다.
@Scripts.Render("~/bundles/bootstrap")
해결방법
A. BundleConfig.cs에서 ScriptBundle을 Bundle로 변경합니다.
oldCode : bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js"));
NewCode : bundles.Add(new Bundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js.");
B. minification 파일을 사용하지 않습니다.
oldCode : bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.min.js"));
NewCode : bundles.Add(new Bundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js.");
참고
728x90
반응형