How to bundle style and script files using layout in asp MVC?

Here is an example.

Layout1 uses style and script file for header and footer functionality. Sections are declared.

View1 uses Layout1 . It also contains style and script files in order to make this view work. Layout sections are updated using @section Sectioname.

Is there a way to bundle all styles and script files at View1? Should I bundle only files needed for Layout1 and apply it in layout code and add View1 files in @section?

What is a good way to resolve this issue?

1 Answer 1


if the scripts and styles that used in view1, will not be used in another views, the best way is to bundle them only at view1, but if they are common scripts and styles that will be used in many views, bundle them at layout.

  • Is is possible to do the bundling in razor or only in bundle config?
    – John
    Jan 29, 2015 at 10:14
  • as far as I know, we do it bundle config only.
    – mesut
    Jan 30, 2015 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.