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

3
  • 2
    You need to add some detail to this question - type of code you're working on, what you're tried, etc. Commented Apr 5, 2012 at 19:56
  • This article mentions all the main points Commented Apr 5, 2012 at 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 ? Commented Apr 5, 2012 at 20:12

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Thanks I will go through that aricle :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.