[Download Source Code]
How would one start an article based on top of an excellent article from a worthy author? The point of that question is that Scott Mitchell is a fantastic author who recently got an excellent article published at MSDN about the ins and outs of view state.
It is quite a lengthy article - I think that it is at least 10 000 words. I was lucky enough to review that article (as mentioned in the credits of Scott's article) a month ago and I added a few suggestions in.
One of my suggestions that I put forward was regarding the part of where Scott demonstrates that the view state may be saved to the server's disk; the intention being to reduce the download bandwidth that the web browser will have to do and possibly the additional upload of the same information to the server when a post back occurs.
The thought was excellent, I must admit. However, there is a major downfall to his code which could result in ASP.NET throwing an exception stating that view state is corrupted and/or invalid. The reason for the error being thrown is to avoid security exploits which Scott also discussed in his article. The exact reason (or should I say reproduction) of the exception being thrown is a bit complex to explain for the time being but I will explain on the next page of this article.
Figure 1: A screen shot of the exception that Scott's code could raise.
The suggestion that I put forward was to avoid the above issue. Due to the extremely long length of the article, Scott could not fit my suggestion in his article (although he did give a hint of my solution but I think it was too brief)… and that is what this article will discuss - using hidden fields and global unique identifiers combination.
Note: I will be referencing to Scott's article at regular intervals so I would recommend that you read his article before continuing reading this one.