ASP.net ViewState

Go To StackoverFlow.com

2

where is asp.net testing if a viewstate is valid and what happens if it is not valid?

Do I have to validate the ViewState by myself?

Asp.net 3.5

BR Thanks

2012-04-05 19:52
by user26411
You need to add some detail to this question - type of code you're working on, what you're tried, etc - IrishChieftain 2012-04-05 19:56
This article mentions all the main point - Henk Holterman 2012-04-05 20:03
@ IrishChieftain As far as I understand, ViewState is a block of data stored in a hidden filed , which contains the state of your webpage. The browser will send back the ViewState and then at some point Asp.net checks if the ViewState is valid. I want to know if it is done automatically or do I have to enable the validation somehow? And what happens if the validation fails? What will be send back to the user - user26411 2012-04-05 20:12


5

where is asp.net testing if a viewstate is valid and what happens if it is not valid?

You'll get an exception if ViewState is invalid.

The ViewState is validated when the page is posted back and it happens before the Page_Load (LoadViewState green box on the pic below) event is raised. Read here. for more details

enter image description here

2012-04-05 20:05
by Icarus
Thank you you already helped me a lo - user26411 2012-04-05 20:17
Nice answer :) + - IrishChieftain 2012-04-05 20:24


1

I can only recommend you reading this excellent article about ViewState and the ASP.NET lifecycle. It opened my eyes and I think it would help you understand how ViewState works. It has a section about validation and security:

http://msdn.microsoft.com/en-us/library/ms972976.aspx

2012-04-05 20:06
by aKzenT
Thanks I will go through that aricle :- - user26411 2012-04-05 20:18
Ads