Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random Invalid Viewstate Error

I know there are a lot of questions on this topic and I have read them all.

I'm using IIS8, .Net 4.5.

Users randomly get an invalid viewstate error, I can't figure it out. Once this happens the only way they can get back into the site is to clear browser cache.

In my web.config I have:

<system.web>
<machineKey validationKey='....key here'   decryptionKey='....decrypt key is valid here'   validation='SHA1'/>
    <!--<hostingEnvironment shadowCopyBinAssemblies="false" />-->
    <authentication mode="None" />
    <compilation targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
...
</system.web>

I'm running on a virtual private server, and I've yet to find a viewstate larger than 9kb.

My application pool is set to restart at 3:00am, once per day.

My page uses update panels, maybe the user is clicking 'back'? But I've seen it happen just visiting the page with no clicking back.

One thing I noticed is I have 3 different sites using the same application pool identity, but the application pools are seperate. There is no machine keys in machine.xml, but only in my web.config.

like image 725
prospector Avatar asked Jun 23 '15 15:06

prospector


1 Answers

A couple of possibilities to investigate:

  1. Update panels are changing form field values (which are what is used to compute ViewState), then the page gets POSTed back to the server, where the new values make validation fail. See this post

  2. You have caching enabled (perform a trace of HTTP headers - make sure you don't have dev tools open) which is causing invalid ViewState to be generated w/ UpdatePanel gumming things up.

  3. Are you using Server.Execute anywhere? (see above link for same)

  4. (less likely) Does your "Virtual Private Server" get migrated to different hardware (perhaps without you knowing it)?

like image 107
Josh E Avatar answered Sep 22 '22 14:09

Josh E