Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:41:04+00:00 2026-06-04T15:41:04+00:00

I’m trying to use http://blogs.msdn.com/b/cdndevs/archive/2012/01/23/javascript-and-css-minifying-bundling-with-the-microsoft-web-optimization-nuget-package.aspx To minify and bundle my css and js files

  • 0

I’m trying to use

http://blogs.msdn.com/b/cdndevs/archive/2012/01/23/javascript-and-css-minifying-bundling-with-the-microsoft-web-optimization-nuget-package.aspx

To minify and bundle my css and js files

All the examples I have been able to find all include all of their scripts on the masterpage / _layout file.

I would like to be able to have a

 @RenderSection("Script", false)

in my _layout file and add scripts from my “subviews” like this

@section Script {
<script src="@Url.Content("~/Scripts/Configuration/Configuration.js")" type="text/javascript"></script>
}

Now my question is how I dynamically add files to the bundle and force a cache bust?

Right now i have this

 public static void AddBundleFile(this HtmlHelper helper, string path, Type type, int index)
    {
        var bundle = BundleTable.Bundles.GetRegisteredBundles()
            .Where(b => b.TransformType == type)
            .First();

        bundle.AddFile(path);
    }

To add files from my “subviews” but the bundle files is never updated..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:41:05+00:00Added an answer on June 4, 2026 at 3:41 pm

    I’m not 100% sure what part you’re having problems with. It sounds like you want to include bundles dynamically? I’d really try to stay away from using any mechanism that dynamically grabs JS and then merges / combines it in any particular order.

    Sooner or later, you’re going to need fine grain control over what JS is included in what order. The sooner you address this the more future proof your app will be. Its frustrating that they even built the ability to just bundle all scripts in a folder automatically, that’s such a bad idea.

    So you’re left with the extremely minor annoyance of having to specify the order of inclusion for your javascript files and bundles. We do this by maintaining a simple List<string> that is consumed in app start.

    Right now I think for our use, we can get by on just one big bundle for the site, but I could see setting up the ability to specify bundles and then specifying the order of inclusion for the bundles as well. In the end you’re just going to end up with a List<T> to go over.

    Here’s what our scripts partial looks like, it lets us dynamically switch between using a bundle or using individually included javascript files:

    @if (NameSpace.UI.UseBundledResources) // set in the web.config, different per environment
    {
        <script src="@Url.ContentNoCache("~/bundle.js")" type="text/javascript"></script>    
    }
    else
    {
        foreach (var file in NameSpace.UI.JavaScriptFileNames)
        {
        <script src="@Url.ContentNoCache(file)" type="text/javascript"></script>  
        } 
    }
    

    and our app start

    var customJsFiles = NameSpace.UI.JavaScriptFileNames;
    var myJSBundle = new Bundle("~/bundle.js", typeof(JsMinify));
    customJsFiles.ForEach(f => myJSBundle.AddFile(f));
    BundleTable.Bundles.Add(myJSBundle);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.