If you have too many javascript file includes with a compositescript in a script manager you get this error…
“The resource URL cannot be longer than 1024 characters. If using a CompositeScriptReference, reduce the number of ScriptReferences it contains, or combine them into a single static file and set the Path property to the location of it.”
I know how to fix this using a plane old asp:scriptmanager (use script manager proxies). But how do I fix it using a ToolkitScriptManager?
<ajaxToolkit:ToolkitScriptManager ID="GeneralScriptManager" CombineScripts="true" CombineScriptsHandlerUrl="Utility/CombineScriptsHandler.ashx" runat="server" AsyncPostBackTimeout="480" EnablePageMethods="true">
<CompositeScript>
<Scripts>
<asp:ScriptReference Path="JavaScript/jQuery/jquery-1.4.1.min.js" />
... A whole lot more script references here
</Scripts>
</CompositeScript>
</ajaxToolkit:ToolkitScriptManager>
Update
I’ve tried doing this with the script combiner included in the sample application. I think it’s right, but I’ve been wrong plenty of times before… No luck though.
Another update So, I thought that maybe if I included multiple CompositeScript blocks within the single ToolkitScriptManager it might create them all as separate files. Nope. Still get the same error. No one has any ideas? When I Google “toolkitscriptmanager cannot be longer than 1024 characters” this StackOverflow question is the number 1 result…
The MSDN documentation on this is actually pretty good:
If you’re looking to combine multiple physical files, you’re going about it the wrong way – see the link below [1]:
What I would look for is a post-build task that combines your static *.js files, something like [2].
Good luck.
[1] –
http://weblogs.asp.net/bleroy/archive/2008/06/12/script-reference-profiler.aspx
[2] –
http://encosia.com/2009/05/20/automatically-minify-and-combine-javascript-in-visual-studio/