VS2012 - Web Forms - Bundling Confusion VS2012 - Web Forms - Bundling Confusion asp.net asp.net

VS2012 - Web Forms - Bundling Confusion


UPDATE: This is a new blog post which also talks about this more: ASP.NET article

Basically webforms + bundling looks like this due to a bunch of legacy behavior that we weren't able to change in scriptmanager.

In regards to your specific questions:

  1. Basically this is so deduping works correctly, script manager has a limitation for the origional script resources which prevents them from being scriptmapped, so they need to be mapped to disk which then gets properly deduped because the files are already included in the bundle.The WebformsBundleJs is a script mapping that is created inside of the PreAppStart code inside of the ScriptManager nupkgs. (I agree this is nearly impossible to discover)

  2. New 4.5 features like unobtrusive validation required jquery(via scriptmanager), which is why script manager was used to ensure jquery doesn't get rendered out twice.

  3. This will work fine, but it will never dedupe with ScriptManager. So for modernizr it won't be an issue.

  4. The jquery packages drop the jquery files to disk in your Scripts folder.

  5. That reference pulls in the msajaxbundle which contains all of the ajax scripts, if you don't need/want them, I think its safe to remove.


I had more or less the same questions also...

However regarding question 4 I have a different opinion.

the WebFormsBundle and MsAjaxBundle are both Script references that have been defined in the PreAppStatCode (like you I cannot find where is this file).

So, I have the feeling that in the same place (ScriptManager.WebForms PreAppStartCode) by default there is another definition for jquery and jQueryUI script reference. These references are used in the script manager.

This process is quite important since because in this way you take advantage of some important feature such as CDN etc. In the definition of jquery in the PreAppStartCode for this specific reference there is a defined CDN path that will be used in case that you activate the EnableCDN in the script manager of your master page (EnableCdn="true")


Just to clarify something from the accept answer explanation for Question 1:

The reason for the script references for the individual web forms js files is to allow the local files (such as "~/Scripts/WebForms/WebForms.js") to override the same files that exist in the System.Web.dll (If you reflect the System.Web.dll and look in the references folder you will find the same .js files).