I've got an ASP.NET web forms application, running on .NET 4.5 using the new Bundling and Minification features from the Microsoft.AspNet.Web.Optimization package.
So far it's a very simple setup just with a single bundle.
BundleConfig.cs
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/send").Include(
"~/scripts/GrowingInput.js",
"~/scripts/textboxlist/TextboxList.js",
"~/scripts/textboxlist/TextboxList.Livesearch.js",
"~/scripts/combobox/ui.combobox.js",
"~/scripts/jquery-ui-timepicker.js",
"~/scripts/msp.send.js"));
}
Global.asax
protected void Application_Start(object sender, EventArgs e)
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
Send.aspx
<%: Scripts.Render("/bundles/send") %>
This is always rendered in a web browser as <script src="/bundles/send"></script>
ignoring whether debug is set to true or false in web.config.
I've tried adding BundleTable.EnableOptimizations = false;
to BundleConfig.cs to force bundling off but this makes no difference.
Looking to get the following working like it does in MVC sites (Microsoft documentation seems to suggest web forms should be the same).
- Get bundling to turn on/off with the debug flag
- Append the cache-busting ?v=xxx querystring for versioning.