Invalid viewstate error

前端 未结 9 646
盖世英雄少女心
盖世英雄少女心 2021-01-31 05:19

I\'m getting an invalid viewstate error with regard to the ScriptResource.axd. Just wondering if anyone of you could help me on this. Error is:

2009-02-24 09:46:30,02         


        
相关标签:
9条回答
  • 2021-01-31 05:45

    I would suggest looking at this...it basically outlines some cases where this can happen depending on the doctype. We had a similar issue, and it seemed to only show up erratically...for us it was a conflict between our XHTML doctype and the javascript we had on the page. We were able to solve it by insuring that all of our javascript was correctly wrapped in tags.

    <script>
         mycode;
    </script>
    

    would become

    <script>
    // <![CDATA[
        mycode;
    // ]]>
    </script>
    

    This may not be an identical issue, but if you have an xhtml doctype, look to see if you have unescaped characters that are not legal XML somewhere (such as '<' characters).

    0 讨论(0)
  • 2021-01-31 05:48

    How large is the view state? Some proxy servers will truncate a large view state.

    It is easy to abuse viewstate since it is turned on by default. If you do have a large viewstate then you probably want to look into disabling view state on controls that do not need it.

    0 讨论(0)
  • 2021-01-31 05:57

    This can happen if the machineKey of the app pool that receives the request for scriptresource.axd is different from that of the app pool that served the original page. This is most likely if you're using a web farm. It can also happen on a single server if the app pool restarts, as a new machine key will be generated. The solution to either is to put an fixed machineKey in your web.config.

    0 讨论(0)
  • 2021-01-31 06:00

    I'm getting the same errors, they actually just started in the last month or two, its been happening on a couple of our sites and we haven't changed any of them since December. This makes me think a configuration change or windows update is effecting it.

    0 讨论(0)
  • 2021-01-31 06:03

    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 (edit: link now requires login for some reason, sorry)

    ... 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.

    This blog post also describes the bugs: 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/partial workarounds (e.g this one) 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

    0 讨论(0)
  • 2021-01-31 06:06

    Same error here for User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 6.0; Trident/4.0; GTB5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618)

    I tried modifying/removing doctype declaration and warping the javascript in // <![CDATA[ and there are still exceptions...

    For the moment all came from the same IP

    0 讨论(0)
提交回复
热议问题