开发者

where and how to use Page.RegisterRequiresViewStateEncryption()?

I would like to know how to register a control with viewState encryption. The syntax of Page.RegisterRequiresViewStateEncryption()开发者_如何转开发 method does not indicate particular control other than the page object. Provide a sample code to answer this question would be very helpful.


RegisterRequiresViewStateEncryption() is to be used with the ViewStateEncryptionMode property of the Page object. That property supports three values:

  • Always: The page's view state will always be encrypted.
  • Never: The page's view state will never be encrypted, even if RegisterRequiresViewStateEncryption() is called by a control or the page itself.
  • Auto: The page's view state will be encrypted only if RegisterRequiresViewStateEncryption() is called by a control or the page itself.

So, if you call Page.RegisterRequiresViewStateEncryption() from, say, one of your control's OnLoad() method, or from the OnLoad() method or Page_Load event of your page, the view state will be encrypted, unless your page's ViewStateEncryptionMode property is set to Never.

The first link above contains a code sample that enables view state encryption on postback if the end user chose to retrieve sensitive information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜