asp.net - how to stop viewstate going stale? -


i have asp.net web forms app uses html5 "offline web apps" technology store pages in browser cache extended period of time. in case it's possible user press button on form , postback when it's days or weeks since form fetched server (i.e. long time interval between , post requests).

sometimes, postback fails classic "validation of viewstate mac failed". question in 2 parts:

  1. what causes viewstate go stale? i.e. how can replicate problem on demand?

  2. is there can make sure never happens? bearing in mind there advice saying should never disable viewstate mac.

you may able solve adding machine key web.config file.

you can use online tool generate machine key, eg. http://www.developerfusion.com/tools/generatemachinekey/.

in web.config goes under configuration > system.web.

it won't help, though, if make changes web form or form listitem values, etc.

you may best not using asp.net form , instead submitting via ajax or using html form (but still using asp.net web forms).

updated

one of reasons viewstate can go "stale" if application pool recycles or stops/restarts. default settings in iis result in website shutting down if there no requests within amount of time restarting again when request comes in.

one way can test (1) open web form on site (2) make change web.config file , resave (3) submit form. if don't have machine key viewstate error @ point.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -