Collin Dauphinee
Collin Dauphinee

Reputation: 13993

How do I dynamically prevent ASP.NET view state from being validated or deserialized?

Given some shared code that is executed on the Init phase and passed a reference to the page the request is being made to, how can I prevent the page's view state from being validated or deserialized?

I've tried the obvious approach of setting the page's ViewStateMode to Disabled, but view state validation still occurs.

In my specific scenario, I have a shared piece of code that knows view state validation is going to fail. I want to prevent the validation exception, as the user is going to be redirected at the beginning of the Load phase. The redirect is done by third-party code, and I don't know where it is going to redirect to, which prevents me from doing the redirect on Init.

Upvotes: 1

Views: 195

Answers (1)

moarboilerplate
moarboilerplate

Reputation: 1643

If your only recourse is to set EnableViewStateMac to false, you're out of luck. ViewState validation is now mandatory.

http://blogs.msdn.com/b/webdev/archive/2014/09/09/farewell-enableviewstatemac.aspx

Upvotes: 2

Related Questions