0

I'm using Angular Elements in C# MVC project.

When I include angular elements build file directly in main.cshtml like <script type="text/javascript" src="~/Script/Angular/artifi-graphics.js"></script> it's working perfectly.

BUT

when I try to add build file in the bundle

bundles.Add(new ScriptBundle("~/bundles/Layout_8_CommonModule")
                .Include("~/Script/Angular/artifigraphics.js")

then the project is not loading.

In console network status of the request is pending and after some time it gets failed. enter image description here

12
  • Possible duplicate of ASP.NET MVC Bundle not rendering script files on staging server. It works on development server Commented May 29, 2019 at 10:17
  • @RahulSharma already tried this solution but not working Commented May 29, 2019 at 10:25
  • Okay, have you tried this link: mariusschulz.com/blog/… Commented May 29, 2019 at 10:28
  • yes tried this also but no luck Commented May 29, 2019 at 10:32
  • Unlike .NET references, Javascript files need to load based on the order. Angular App should be loaded first, then the related components. You would have to include it in the app file using Include method instead of IncludeDirectory method. Commented May 29, 2019 at 10:41

1 Answer 1

1

after searching a lot find out C# bundling is not so intelligent to bundle angular production build files which are also merged by node concat library.

so I just added angular bundle into main.cshtml file just like we add scripts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.