Is there any way I can simulate a proxy server truncating a viewstate?
Asked
Active
Viewed 1,426 times
0
-
Yikes, which proxies do that? – JonoW Jul 29 '09 at 14:48
-
I wonder why would any sane proxy server truncate anything from the HTML transmitted from the server. – Anton Gogolev Jul 29 '09 at 14:48
-
Based on the research the I have done, some proxy servers will truncate the viewstate if it is too large. – Miyagi Coder Jul 29 '09 at 14:56
-
I guess I can truncate the viewstate variable in the request object efore it loads/validates...Any better alternatives? – Miyagi Coder Jul 29 '09 at 15:02
2 Answers
2
I avoid ViewState client-side entirely by putting it server-side. The code is about 5 lines long and I've seen a tremendous improvement in performance.
http://aspadvice.com/blogs/robertb/archive/2005/11/16/13835.aspx
You could fake a tampered viewstate easily using fiddler:

Keith Adler
- 20,880
- 28
- 119
- 189
-
There's also a good article on CodeProject about using the Provider model to store ViewState in a database: http://www.codeproject.com/KB/viewstate/ViewStateProvider.aspx – Dan Diplo Jul 29 '09 at 15:50
1
How have you ascertained it is a proxy server? It doesn't sound likely that a proxy server would truncate parts of the HTML.
However, if ViewState is interfered with then ASP.NET will throw an Invalid Viewstate exception. So, erm,
throw new System.Web.UI.ViewStateException();

Dan Diplo
- 25,076
- 4
- 67
- 89
-
1http://support.microsoft.com/kb/555353 - Intermittent Invalid Viewstate Error in ASP.NET Web pages – Miyagi Coder Jul 29 '09 at 15:00