Asp.net 4.5 script binds and doesn't bind

I upgraded the project from asp.net 3.5 to 4.5 to use script binding and javascript minimization. Now everything works for me, and all the scripts come out in the kit that I defined, but they are not "combined" together into one script, and they are not reduced.

Here is what I have ...

default.aspx contains the following:

<asp:ScriptManager
ID="scriptmanager"
LoadScriptsBeforeUI="false"
runat="server"
    ScriptMode="Release"
    EnableScriptLocalization="false"
>
    <Scripts>
        <%--Framework Scripts--%>
        <asp:ScriptReference Path="~/bundles/MyBundle" ScriptMode="Release"/>
        <%--Site Scripts--%>
    </Scripts>
</asp:ScriptManager>

Application_Start in Global.asax:

BundleTable.EnableOptimizations = true;
BundleConfig.RegisterBundles(BundleTable.Bundles);

Bundleconfig.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;

namespace MyNameSpace
{
    public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254726
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/MyBundle").Include(
                "~/Scripts/WebForms/WebForms.js",
                "~/Scripts/WebForms/MSAjax/MicrosoftAjax.js",
                "~/Scripts/WebForms/MSAjax/MicrosoftAjaxWebForms.js",
                "~/Scripts/WebForms/TreeView.js",
                "~/Scripts/WebForms/Focus.js",
                "~/Scripts/WebForms/MenuStandards.js"));

        }
    }
}

I even disabled debug in web.config, although I am trying to force release mode in the scriptmanager as well as the script link.

<compilation debug="false" batch="true" targetFramework="4.5">

There are still a few links in the output:

<script src="/MyProj/WebResource.axd?d=pynGkmcFUV13He1Qd6_TZA6EiyQ1YRW47qIzscWLzWU7jP_7DjoC2XbU7kCBkgYcJdoeAwqaVpUMnbWRsvhdMw2&amp;t=634896541540000000" type="text/javascript"></script>
<script src="/MyProj/ScriptResource.axd?d=zvkqIRNUspAvS1yKeFhMb4kS_IY-Q_9Yn_KOfmzKLnliETz8uip5T2BUr1JOPE4XV1bmnifY3Eg8vrX8bPLYT71P0Kf8DwEcoRw5fj2tqHdQSorRXVpasfsMXeJLHbT_alkHjf2wIrgxLzxYvocKIA2&amp;t=12e197aa" type="text/javascript"></script>
<script src="/MyProj/ScriptResource.axd?d=NJmAwtEo3Ipnlaxl6CMhvpbyEkpQU7AWZ3ZOrSRn7cdqTBUwP_3lu0l46EnEFBAkBOoC5I7IpMnx8u7VKe4fESCWGvycDq7dTXHsUSTg-j9u4S2Poz38UkmBa7Ta1cXyZ9DcFfKo7RpgjmNNoFjlZgbsHJEPN_AnazProCOQuws1&amp;t=6119e399" type="text/javascript"></script>
<script src="/MyProj/ScriptResource.axd?d=dwY9oWetJoJoVpgL6Zq8OPgCkw9mWNaQmhnwlbrOgCXqxXAsNin9JxaUjtv38gzHz78sozRMjuXYeM_GE0v4htSt6vWwOO4-gOCLfSt6rVOvxbpcCXCLN9jI7fWPkTL2Eq7a9kcN8S4MasueIxDV0rhf-htD32XuwA259deRSNs1&amp;t=6119e399" type="text/javascript"></script>
<script src="/MyProj/WebResource.axd?d=JoBkLzP19aTuxbWOhHobYmKZKUo0k_GoCFbuT9i-BqZJQhy_7Dl0oCPSUy3hiGltbFyiUTxWBZD-5YWblJpSZg2&amp;t=634896541540000000" type="text/javascript"></script>

What am I missing? How can I get all the scripts in the kit to display only one link and minimize the code inside?

Thanks J

+5
source share
2

, <asp:ScriptReference /> . MVC :

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

( , src ):

<script src="/bundles/lib?v=gGKSj7TFmjDTZAjdEzBrqOOu9aGB6i4Tq0mHfaLUk_c1"></script>

, System.Web.Optimization.Scripts, Render() <asp:ScriptReference />.

, :

var myBundle = new ScriptBundle("~/bundles/MyBundle").Include(
                "~/Scripts/WebForms/WebForms.js",
                "~/Scripts/WebForms/MSAjax/MicrosoftAjax.js",
                "~/Scripts/WebForms/MSAjax/MicrosoftAjaxWebForms.js",
                "~/Scripts/WebForms/TreeView.js",
                "~/Scripts/WebForms/Focus.js",
                "~/Scripts/WebForms/MenuStandards.js")
myBundle.Transforms.Add(new JsMinify());
bundles.Add(myBundle);
+1

Scripts.Render ScriptManager

<%: Scripts.Render("~/bundles/MyBundle") %>

:

System.Web.Optimization.Scripts.Render("~/bundles/MyBundle")
+1

All Articles