+1  A: 

Ok, welcome to the living hell that is MS ajax.

this bit is interesting

Requested Url : http://garmn.factoryoutletstore.com/ScriptResource.axd?d=y9_dUwBeGqLlRpT5Dml1zhoQvfa7NKdj69EYuV771kzSsa5KOOXBfJZjk if (cat_gallery != Message: Invalid viewstate

that "if (cat_gallery !=" looks sort of out of place. I would look at the javascript around that if and see if there is anything that looks fishy

Assuming you are using update panels, that bit about invalid viewstate leads me to think that viewstate is getting borked between partial requests. My guess (not based on fact, more on experience and pain) is that it is one of two things; either you have multiple panels and state is getting out of whack (panel 1 updates state, panel 2 fires right after and doesnt pick up the changes), or that it is page lifecycle related (i have seen multiple databinds cause invalid viewstate in partial page postbacks)

I would say first thing is to try and reproduce the error. Go to the page that it happens on, and try every combination of behavior you can think of. Once you have a reproducible bug, attach a debugger and put breakpoints all over, then just step through the page lifecycle and see if there are any code paths wandering in directions you didn't anticipate.

Either way, MS AJAX is extremely black-boxish, so debugging issues around it can be excruciatingly difficult (spent about 20 hours doing what I just recommended to you last week) I wish you the best of luck, and really hope that this helps you down the right path.

Matt Briggs
I sympathize. I'm sick enough of it, that we are most likely going to switch to an MVC framework and do all the AJAX ourselves with jQuery. When I spend 5 hours working around a viewstate problem to do something that should take 20 minutes total, it makes me very angry..
gregmac
A: 
JamTech
+1  A: 

These errors tend to happen if you are hosting your site on a load-balancing cluster or in a web farm. If you deploy your application in that environment, you must ensure that the configuration files on each server share the same value for validationKey and decryptionKey, which are used for hashing and decryption respectively. This is required because you cannot guarantee which server will handle successive requests.

With manually generated key values, the settings should be similar to the following example. Please make sure element is underneath section in the web.config file.

<machineKey validationKey="0BE61B38B9836B541C45728ADB9D93A6FD819169DBB6AD20078A70F474650CC0295C69131E083A6B3762C457BBAF3E66E18F294FDA434B9DD6758631A90A2E20" decryptionKey="B80CC12266B36CCF35EF0708DB5854EDA3BBEBA1A7C89A4E" validation="SHA1"/>

Here's a nifty little key generator which you can use to generate the key values - http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx

So as you might have guessed, the d parameter in the ScriptResource.axd is actually the decryption key, and when that key does not match with the previous request .NET framework will throw an invalid view state error.

Hope that helps!

jesal
I taught the d parameter was the encrypted assembly name and version that is being requested by the handler class for the scriptResource.
JamTech
You are right. I incorrectly assumed the d parameter was the decryption key. By looking into it more I came across this blog - http://tinyurl.com/5dhqzb which points to a completely different reason as to why those errors might be happening. Although I was able to fix them by adding the machineKeys.
jesal
Hey glad you got yours fixed. Are you running server farm? The issue is am not I dont think the machinekey will help. What i have notice is that problem seems to center machines running vista with IE8,FF3,MAC OS X. I begin to wonder if script tag and xhtml in these new browser are is the issue
JamTech
My site was running on a Win Server 03 load balancing cluster. After I added the machineKeys the errors stopped. Although I didn't see any JavaScript code mixed up with the d parameter like in your case. That is indeed strange. Are you using a CombinedScripts handler in the ScriptManager?
jesal
A: 

Hey Beska, I started look into this issue about a week now as well, and I still haven’t had any luck with it. I also have the web Resource issue as well but I was trying to investigate the script Resource first. I ran a query on my error log and I saw that this error goes as far back as April 24 2008.

I am running my sites on a web farm with a load balancer but none of that is setup right now. Right now I am just serving the sites from one server as I am using the other as my DEV box. So that rules out the Machine Key Issue for me. I am also not using web gardening on any of my boxes.

JamTech
A: 

This might be a dumb answer, but have you checked your session state manager? the default is IN PROC which does not work with a web farm, you need to use SQL or some other state manager.

Decker97
I ruled out web farms as I am not using it, in the initial setup the system was being design to work on web farm, but it was never completed Hardware wise I only launched on one server and I have even disabled web gardening, so I don’t think it s state issue. Thanks for your suggestion.
JamTech
+5  A: 
JamTech
This has solved my issue hope its hepfull to someone else.
JamTech
So to be clear, was it adding a doctype that solved it? If so, what doctype did you use?
Brian MacKay
Or did you just wrap everything in CDATA? And also, if you use script tags and use src rather than putting the javascript on the page, do you still get these problems?
Brian MacKay
+2  A: 

We've experienced the same and it appears to be related to a bug in IE8's rendering engine.

Take a look at the following resources: http://blogs.msdn.com/ieinternals/archive/2009/07/27/Bugs-in-the-IE8-Lookahead-Downloader.aspx http://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=467062

Basically there are a few tags on the page that are causing a "parser restart" which causes 4K of the HTML in the page to be omitted. This means that the browser is putting HTML on to the ScriptResource.axd that occurs 4096 bytes later in the page.

Jonathan Oliver
+1  A: 

I think these errors happen with different browsers for different reasons, which is what makes it so hard to track down.

IE8 Bug

Microsoft have said a bug in IE8 will (in some circumstances) generate spurious requests to the server, that do not affect the user but do lead to errors being logged at the server side.

See this discussion here: Bug IE8 – 4K dropped - "Invalid viewstate" when loading ScriptResource.axd

... particularly EricLaw-MSFT's update when he says:

It is worth mentioning that anyone who is experiencing a problem here in IE6/IE7 or Firefox is encountering a different problem that is not related to the IE8 issue described below.

See also Bugs in IE8's Lookahead Downloader

They say changing the way you set Content-Type will help with some of the errors, although not all of them - they say it is caused by various obscure circumstances that they are still looking at.

Update: As of 01/Apr/2010, these IE8 bugs have been fixed, via IE8 Cumulative Update (KB980182).
This post: IE8 Lookahead Downloader Fixed gives more detail on the bugs and other possible workarounds other than waiting for everyone in the world to download the fix.

Other Browsers

Haven't figured it out yet, but other browsers are also generating these errors, presumably for different reasons.

Web Farms

This problem is not restricted to sites running on web farms, but if you are running a farm, check out this answer by jesal which may help

codeulike