If I use the CompositeScript feature of the ASP.NET ScriptManager/ScriptManagerProxy controls, I cannot get the Path attribute to work:
My code
<asp:ScriptManagerProxy ID="scriptProxy2" runat="server">
<CompositeScript Path="~/Includes/Javascript/Combined.js">
<Scripts>
<asp:ScriptReference Path="~/Includes/Javascript/MyFile1.js" />
<asp:ScriptReference Path="~/Includes/Javascript/MyFile2.js" />
</Scripts>
</CompositeScript>
</asp:ScriptManagerProxy>
My page gets the correct script tag in it:
<script src="../Includes/Javascript/Combined.debug.js" type="text/javascript"></script>
But of course, that file doesn’t exist and so the browser gets a 404.
Am I missing something?
Have you specified source scripts to get combined using
ScriptReferencetag – see the documentation.EDIT: After using reflector, I discovered that if you use specify
Pathattribute, the script combining does not happen – it just emits script ref to the path specified (modifying as per release/debug mode and culture (if localization is enabled)). After googling around, found that intended use of path property is to work around url limit of 1024 characters. From this MSDN documentation:I have also stumbled upon this link where there is a wealth of information in comments section. One such comment clearly states that
So in summary, I think that how you intend use the combine script is neither supported nor recommended. I will suggest that you use build time script combining – below resources will help you in achieving the same:
http://encosia.com/2009/05/20/automatically-minify-and-combine-javascript-in-visual-studio/
Look at mashing feature in Chirpy add-in: http://www.weirdlover.com/2010/07/18/chirpy-attains-godlike-abilities-in-version-1-0-0-4/#mash