Asp.Net MVC Bundle does not Render

Asp.Net MVC 4.5 introduced Bundling resource for styles and for scripts. Its role is to minimize the size of your resource by aggregating files in 1 and reducing the size by compressing the string. In Asp.Net 5, it’s gone. Asp.Net team with the newest version took out some features that can be handled by non-Microsoft solutions. However, the Asp.Net MVC 4.5 bundling is still present in many websites. One problem that can occur is that your styles render but not your scripts. This problem is the result of the hidden rule which is that your CSS bundle name cannot be the same name of your script. If you created a style bundle with the name of your page, you cannot have the same one for your script. It’s better to prefix it with your intention.

This is an example that will render only CSS and not JavaScript.


The solution is to have unique name.


Do not forget to change the BundleConfig.cs file to have names matching Html helpers.

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.