1

how can I add GET to script in ScriptBundle ?

example:

 bundles.Add(new ScriptBundle("~/bundles/baseJs").Include(
                                        "~/Scripts/index.js"
));

and I want to call this script:

 "~/Scripts/index.js?1"

how can I do it ?

heyo
  • 19
  • 2
  • What do you mean _add GET to script_? –  Mar 28 '16 at 06:21
  • add '?1' to make sure it will be update at the client – heyo Mar 28 '16 at 06:27
  • What do you mean _update at the client_?. If you have `@Scripts.Render("~/bundles/baseJs")` in you view, and you modify `index.js`, then it will be updated –  Mar 28 '16 at 07:04

1 Answers1

0

Bundles can be called at View(.cshtml) page like:

@Scripts.Render("~/bundles/bundleName")

Replace bundleName with your bundle name & it will render all js files in bundle on that page.

Make sure you use render statement in start of html body.

UPDATE: It's basic advantage of using bundling you can manage version of js with build. Just edit bundlename to add release number & voila all you client were forced to get bundle since it's name is different. We are doing like this.

Earlier we need to manually minify js & added version number to files names too that was configured in web config files. That was painful, bundling is cherry on cake.

Pranav Singh
  • 17,079
  • 30
  • 77
  • 104