3

I'm trying the new Web.Optimizations bundling and minimizer and have followed the examples but it is not generating the token portion of the query string:

bundles.Add(new ScriptBundle("~/Scripts/test")
    .Include(
        "~/Scripts/jquery.validate.min.js"
    )
);

But the rendered HTML is

<script src="/Scripts/test" type="text/javascript"></script>

What happened to the query string token? I expected it to render something like

<script src="/Scripts/test?v=8HZAB6C8ZnrIPYNFzMQKt0AR4AUsUYBjxPPkbGSRIZo1" type="text/javascript"></script>

I do have debug set to false in web.config

EDIT: Just to clarify - the bundling and minimization DOES work. But it is not generating a querystring token in the form of ?v=random

Prix
  • 19,417
  • 15
  • 73
  • 132
JK.
  • 21,477
  • 35
  • 135
  • 214

2 Answers2

4

If you are in debug it does not bundle. Debug must be turned off to get it to bundle using the token.

From tutorial:

Bundling and minification is enabled or disabled by setting the value of the debug attribute in the compilation Element in the Web.config file

You can override that behavior with:

BundleTable.EnableOptimizations = true;
Andy T
  • 10,223
  • 5
  • 53
  • 95
3

You need to use Styles.Render method in your view:

@Styles.Render("~/Scripts/test")

You also need to disable debug mode from Web.config:

<system.web>
    <compilation debug="false" targetFramework="4.5" />
</system.web>
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156