c# - Turning off bundling and minification (WEBFORMS) -
c# - Turning off bundling and minification (WEBFORMS) -
i have created new asp.net website test feature. want able dynamically command whether bundling/ minification can toggled @ runtime. of code self generated shown below except line turning off optimization.
public static void registerbundles(bundlecollection bundles) { // added line turn off optimization. system.web.optimization.bundletable.enableoptimizations = false; bundles.add(new scriptbundle("~/bundles/webformsjs").include( "~/scripts/webforms/webforms.js", "~/scripts/webforms/webuivalidation.js", "~/scripts/webforms/menustandards.js", "~/scripts/webforms/focus.js", "~/scripts/webforms/gridview.js", "~/scripts/webforms/detailsview.js", "~/scripts/webforms/treeview.js", "~/scripts/webforms/webparts.js")); // order of import these files work, have explicit dependencies bundles.add(new scriptbundle("~/bundles/msajaxjs").include( "~/scripts/webforms/msajax/microsoftajax.js", "~/scripts/webforms/msajax/microsoftajaxapplicationservices.js", "~/scripts/webforms/msajax/microsoftajaxtimer.js", "~/scripts/webforms/msajax/microsoftajaxwebforms.js")); // utilize development version of modernizr develop , larn from. then, when you’re // ready production, utilize build tool @ http://modernizr.com pick tests need bundles.add(new scriptbundle("~/bundles/modernizr").include( "~/scripts/modernizr-*")); scriptmanager.scriptresourcemapping.adddefinition( "respond", new scriptresourcedefinition { path = "~/scripts/respond.min.js", debugpath = "~/scripts/respond.js", }); }
my questions follows:
1) under impression enableoptimization supposed turn off optimization , see unbundled scripts in browser without having modify markup. thought scriptmanager automatically handled , pushed out individual js files when sees above mentioned flag.
2) having debug true in web.config trigger enableoptimization false.
are both these assumptions false?
edit
1) this , this similar questions no answers!
edit 2
public class optimizationmodule : ihttpmodule { private const string param_name = "minify"; public void dispose() { //throw new notimplementedexception(); } public void init(httpapplication context) { context.beginrequest +=(new eventhandler(this.context_beginrequest)); } private void context_beginrequest(object source, eventargs e) { // create httpapplication , httpcontext objects access // request , response properties. httpapplication application = (httpapplication)source; if (application != null && application.request.querystring[param_name] != null) { bool minify; bool.tryparse(application.request.querystring[param_name], out minify); if (!minify) { bundletable.bundles.clear(); bundleconfigs.generatebundles(bundletable.bundles, false); } else { bundletable.bundles.clear(); bundleconfigs.generatebundles(bundletable.bundles, true); } } } }
i tried adding httphandler allow luxury changing optimization while running application. thought pass : localhost/page.aspx?minify=false on client side view how unminified version looks like, if need debug something. not seem alter anything. mean whatever settings have @ start continued throughout session or can changed.
c# asp.net webforms bundling-and-minification
Comments
Post a Comment