CompositeScript - Invalid ViewState error

I am using the new CompositeScript feature available in ASP.NET 3.5 SP1 for the ScriptManager.

When I test this with ASP.NET Development Server, it works great, but when I publish the site to my IIS web server, the combined files cannot be loaded, I always get the following error: Invalid ViewState.

The request added to the ScripResourceHandler is quite long (reason?):

<script type="text/javascript" src="/ScriptResource.axd?d=8PM7kHuMMquT4Ta6cvC_2JLE_mKmYLeDWgV9z71Ryu5-7LRuy1v7MkEzM-M-NoE92QPDzXGBBSohhGbO17FKHqTZ9xMJx_5WaNrJTiwoFF28dlc6k02jRhN73u_Ohv7CKe-QPUdCOnzsBblNlopier7Ijd66Jp6Z0voAkZp36RzWYd64G9SOBCUs1HTu7oRQJTOlWyAd26O2r3S7Js7VX1YddtK-zO7DHa272a5-BitDkKTubnMPlwyYnW0Cn7TVK7NCjyF_o1E6wgPWY4THH56YNMtyRKeTrGFzMjTkiOmv18i2ePMHErlWYBXiL0If47bfPbNtfIeAMQAT8xX_DMBN6VR74GDlJSXQpFcGadNsKocZ4EOonDLykWf6Oq4ISr54_c-k_zzma5f6qFk1fXx8n8Vphe_QL67R-7aDlwBH9CrK-IBsuYDDeMSlTMWAZ6TRIhZSAyVANvh2VPZ8eBmGD0BpVA7D8e2vA1l6_kbC7w6CmGCEok-Cb1dqQPjgwB6Ho199M3IWrdwbUkN2leiDXn9bkZMGWA75IyjYiDisAz97JyA9AtDolhYGbxJ_AVrIpNpZFOQBZsXBkLfoo7iZmzHLwG7HNPhodtaekPAcxiKgi7Xf62DEnb20VRYMCFH8Qzfx5u4nlzZo4n7ZMkxDpWPlB65LCeCtvC6ZIl1kbq9FJ9dlf_DAkNU3-KKy__87Tzz9RWx6ucLXRGuljodLjiT8wrWRET_CpCspnHqpByBxEXiOi1_jW0e6_GjfZ9Fqk9GIXsSoTvnZmz_J68d28rSafQVKO1O06AjHCCBd7wh5mY-ISSLFaZ0pPszjdgVYxnC83ujaY9SWmRxUb_lPT4VdYG1Q02iyRO2l7BIDO-NiF77V_kklBhQRZ5ZiT3Vbf-JL6EZISThBJuh3WA2">

      

Does anyone know a solution to this problem?

+1


source to share


2 answers


I think the ScriptResource.axd reference is not valid.

AFAIK, the request that is present in ScriptResource.axd has two parameters (d and t). D paramater is an encrypted string that contains the assembly, the version number if applicable, and the name of the resource (that is, the javascript file) embedded in the specified assembly. Encryption is machine key based. The t parameter is the date the assembly was updated (in ticks).

If you look at Reflector and look at the System.Web assembly and look at UI.Page, there is a private DecryptString method. I'm not on Windows at mo, but if you look down on DecryptString you can see that you end up with an "Invalid view state" exception.



There are several different ways to create composite scripts and combine script. But I don't think any ScriptManager control (AjaxToolKit has it too) actually got this patch. In practice, I find that you are always left with a few scripts outside.

A few other resources to consider: Omar Al Zabir posts at codeproject: http://www.codeproject.com/KB/aspnet/HttpCombine.aspx and http://www.codeproject.com/KB/aspnet/fastload.aspx . Omar also has a good book that covers productivity.

Also on codeproject Moiz Dhanji has a slightly different approach: http://www.codeproject.com/KB/aspnet/AspNetOptimizer.aspx.

+2


source


Another variation on Omar and Moise's approach that Martin outlined is the work that Christian hired on his N2 CMS project .



The idea is that instead of describing each group of scripts, the configuration file simply creates a virtual subfolder for each group. Then, upon request, the aLL that the custom HTTP handler has to execute is to move the requested directory and process the ALL files found there.

+2


source







All Articles