简体   繁体   English

ASP.net 视图状态

[英]ASP.net ViewState

where is asp.net testing if a viewstate is valid and what happens if it is not valid? asp.net 在哪里测试视图状态是否有效,如果无效会怎样?

Do I have to validate the ViewState by myself?我必须自己验证 ViewState 吗?

Asp.net 3.5 Asp.net 3.5

BR Thanks谢谢

where is asp.net testing if a viewstate is valid and what happens if it is not valid? asp.net 在哪里测试视图状态是否有效,如果无效会怎样?

You'll get an exception if ViewState is invalid.如果 ViewState 无效,您将得到一个异常。

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.回发页面时会验证 ViewState,它发生在引发 Page_Load(下图中的 LoadViewState 绿色框)事件之前。 Read here.在这里阅读。 for more details更多细节

在此处输入图像描述

I can only recommend you reading this excellent article about ViewState and the ASP.NET lifecycle.我只能推荐您阅读这篇关于 ViewState 和 ASP.NET 生命周期的优秀文章。 It opened my eyes and I think it would help you understand how ViewState works.它让我大开眼界,我认为它可以帮助您了解 ViewState 的工作原理。 It has a section about validation and security:它有一个关于验证和安全的部分:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM