Ho aggiornato un progetto da asp.net 3.5 a 4.5 per utilizzare il raggruppamento di script e la minificazione di javascript. Ora ho tutto in esecuzione e tutti gli script vengono visualizzati nel bundle che ho definito, ma non sono "raggruppati" insieme in uno script e non sono minimizzati.asp.net 4.5 bundle di script nè bundling n. Min.
Heres quello che ho ...
il default.aspx contiene questo:
<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"));
}
}
}
Ho persino girato off debug in web.config anche se provo a forzare la modalità di rilascio in scriptmanager e il riferimento allo script.
<compilation debug="false" batch="true" targetFramework="4.5">
L'uscita è ancora diversi riferimenti:
<script src="/MyProj/WebResource.axd?d=pynGkmcFUV13He1Qd6_TZA6EiyQ1YRW47qIzscWLzWU7jP_7DjoC2XbU7kCBkgYcJdoeAwqaVpUMnbWRsvhdMw2&t=634896541540000000" type="text/javascript"></script>
<script src="/MyProj/ScriptResource.axd?d=zvkqIRNUspAvS1yKeFhMb4kS_IY-Q_9Yn_KOfmzKLnliETz8uip5T2BUr1JOPE4XV1bmnifY3Eg8vrX8bPLYT71P0Kf8DwEcoRw5fj2tqHdQSorRXVpasfsMXeJLHbT_alkHjf2wIrgxLzxYvocKIA2&t=12e197aa" type="text/javascript"></script>
<script src="/MyProj/ScriptResource.axd?d=NJmAwtEo3Ipnlaxl6CMhvpbyEkpQU7AWZ3ZOrSRn7cdqTBUwP_3lu0l46EnEFBAkBOoC5I7IpMnx8u7VKe4fESCWGvycDq7dTXHsUSTg-j9u4S2Poz38UkmBa7Ta1cXyZ9DcFfKo7RpgjmNNoFjlZgbsHJEPN_AnazProCOQuws1&t=6119e399" type="text/javascript"></script>
<script src="/MyProj/ScriptResource.axd?d=dwY9oWetJoJoVpgL6Zq8OPgCkw9mWNaQmhnwlbrOgCXqxXAsNin9JxaUjtv38gzHz78sozRMjuXYeM_GE0v4htSt6vWwOO4-gOCLfSt6rVOvxbpcCXCLN9jI7fWPkTL2Eq7a9kcN8S4MasueIxDV0rhf-htD32XuwA259deRSNs1&t=6119e399" type="text/javascript"></script>
<script src="/MyProj/WebResource.axd?d=JoBkLzP19aTuxbWOhHobYmKZKUo0k_GoCFbuT9i-BqZJQhy_7Dl0oCPSUy3hiGltbFyiUTxWBZD-5YWblJpSZg2&t=634896541540000000" type="text/javascript"></script>
Che cosa mi manca? Come posso ottenere tutti gli script nel pacchetto per produrre solo un riferimento e ridurre il codice all'interno?
Grazie, J
http://stackoverflow.com/questions/12018429/asp-net-bundling-minification-including-dynamically -generated-javascipt Leggi i commenti, può essere utile. – Gev
come hai risolto questo problema – MonsterMMORPG