locked
Invalid View State Error RRS feed

  • Question

  • User-2066177896 posted

    Hi All,

    We are getting a Invalid view state error in our application. All these errors are coming from users who are logged in on mobile devices.

    This happens on only one page. This page has a grid which has lots of data.

    We lookoed at our servers and the issue is not with application pool recycling or worker process recycling.

    We tried view state chunking but still getting the issue.

    <html><body>An error occurred in my Application. User 'Skan' requested
    the page /mypage/frm_myform.aspx<br/>Invalid viewstate.
    Client IP: xxxx
    Port: xxxx
    User-Agent: Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; SCH-I800
    Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile
    Safari/533.1
    ViewState:
    /wEPDwUJMjQ0NTc5NDczD2QWAmYPZBYCAgMPZBYGAgkPDxYCHgRUZXh0BRpXZPZBYCZg9kFgQCAQ8UKwACFZBxQrAAJkZBQrAAIPFgIeB1Zpc2libGVoZBAWAWYWARQrAAJkZA8WAWYWAQV0VGVsZXJpay5XZWIuVUkuUmFkTWVudUl0ZW0sIFRlbGVyaWsuV2ViLlVJLCBWZXJzaW9uPTIwMTAuMy4xMjE1LjM1LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQUKwACZBAWAWYWARQrAAJkZA8WAWYWAQV0VGVsZXJpay5XZWIuVUkuUmFkTWVudUl0ZW0sIFRlbGVyaWsuV2ViLlVJLCBWZXJzaW9uPTIwMTAuMy4xMjE1LjM1LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQUKwACZBAWAWYWARQrAAJkZA8WAWYWAQV0VGVsZXJpay5XZWIuVUkuUmFkTWVudUl0ZW0sIFRlbGVyaWsuV2ViLlVJLCBWZXJzaW9uPTIwMTAuMy4xMjE1LjM1LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQUKwACZBAWAWYWARQrAAJkZA8WAWYW...<br/>System.Web.HttpException:
    The client disconnected. ---> System.Web.UI.ViewStateException: Invalid
    viewstate.
    Client IP: xxxxx
    Port: xxxx
    User-Agent: Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; SCH-I800
    Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile
    Safari/533.1
    ViewState:
    /wEPDwUJMjQ0NTc5NDczD2QWAmYPZBYCAgMPZBYGAgkPDxYCHgRUZXh0BRpXZWZg9kFgQCAQ8UKwACFCsAAg8WAh4XRW5hYmxlQWpheFNraW5SZW5kZXJpbmdoZBAWB2YCAQICAgMCBAIFAgYWBxQrAAJkZBQrAAIPFgIeB1Zpc2libGVoZBAWAWYWARQrAAJkZA8WAWYWAQV0VGVsZXJpay5XZWIuVUkuUmFkTWVudUl0ZW0sIFRlbGVyaWsuV2ViLlVJLCBWZXJzaW9uPTIwMTAuMy4xMjE1LjM1LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQUKwACZBAWAWYWARQrAAJkZA8WAWYWAQV0VGVsZXJpay5XZWIuVUkuUmFkTWVudUl0ZW0sIFRlbGVyaWsuV2ViLlVJLCBWZXJzaW9uPTIwMTAuMy4xMjE1LjM1LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQUKwACZBAWAWYWARQrAAJkZA8WAWYWAQV0VGVsZXJpay5XZWIuVUkuUmFkTWVudUl0ZW0sIFRlbGVyaWsuV2ViLlVJLCBWZXJzaW9uPTIwMTAuMy4xMjE1LjM1LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQUKwACZBAWAWYWARQrAAJkZA8WAWYW

    Can anyone help us with this issue?

    Will disabling the view state help?

     

    Thanks

     

     

    Tuesday, November 29, 2011 11:50 AM

Answers

  • User960609757 posted

    Hi,

    Invalid viewstate can happen for a variety of reasons.

    1. Viewstate is too big and has not finished rendering before a user causes a postback on the page. The fix is generally to disable all controls that trigger postbacks and enable them client side once the page has finished loading - see http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
    2. You are using viewstate MACs (and you should be, for security reasons) but you have not set a machine key and the application pool has recycled generating a new one. Don't forget to set a ViewStateUserKey.
    3. Someone is using an old version of IE on the mac where it truncates hidden form fields. In this case you'll need to move viewstate out of the page into session state.
    4. Viewstate MAC issues generally indicate you're on a web farm and have forgotten to set a machine key in web.config. However if you have done this then it is probably someone trying to do bad things (bots posting comments, someone trying to trigger events for disabled controls etc.) The cause of these should be tracked down if only to rule out potential security issues.

    Whatever you do do not turn off viewstate or event validation.

    and check this thread,

    http://forums.asp.net/t/1615477.aspx/2/10

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 2, 2011 5:55 AM

All replies

  • User535082756 posted

    Hi

    Yes disabling the viewstate will definetly help. Try it in the page level or the control level.

    thanks,

    Wednesday, November 30, 2011 8:21 AM
  • User-2066177896 posted

    cninjas,

    Is it a good practice?

    Will it cause any issues if i disable the cviewstate?

     

    Thanks

    Wednesday, November 30, 2011 6:25 PM
  • User960609757 posted

    Hi,

    Invalid viewstate can happen for a variety of reasons.

    1. Viewstate is too big and has not finished rendering before a user causes a postback on the page. The fix is generally to disable all controls that trigger postbacks and enable them client side once the page has finished loading - see http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
    2. You are using viewstate MACs (and you should be, for security reasons) but you have not set a machine key and the application pool has recycled generating a new one. Don't forget to set a ViewStateUserKey.
    3. Someone is using an old version of IE on the mac where it truncates hidden form fields. In this case you'll need to move viewstate out of the page into session state.
    4. Viewstate MAC issues generally indicate you're on a web farm and have forgotten to set a machine key in web.config. However if you have done this then it is probably someone trying to do bad things (bots posting comments, someone trying to trigger events for disabled controls etc.) The cause of these should be tracked down if only to rule out potential security issues.

    Whatever you do do not turn off viewstate or event validation.

    and check this thread,

    http://forums.asp.net/t/1615477.aspx/2/10

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 2, 2011 5:55 AM