Encrypting view state is used to reduce the chance of information disclosure and some one getting information to cause harm to the user.
In Asp.net 2.0 the support for encryption has been enhanced. Now you can define encryption of view state on Page level. Following is the implementation in the Page tag of the aspx file.
<%@ page language="c#" masterpagefile="~/MasterPage.master" inherits="Abc.Default, App_Web_Default.aspx.cdcab7d2" validaterequest="false" theme="ABC" viewstateencryptionmode="Always" enableEventValidation="false" %>
The attribute ViewStateEncryptionMode has three values.
1) Auto
2) Always
3) Never
The default for ViewStateEncryptionMode is Auto.
We can also set its value in the web.config file as
In Asp.net 2.0 the support for encryption has been enhanced. Now you can define encryption of view state on Page level. Following is the implementation in the Page tag of the aspx file.
<%@ page language="c#" masterpagefile="~/MasterPage.master" inherits="Abc.Default, App_Web_Default.aspx.cdcab7d2" validaterequest="false" theme="ABC" viewstateencryptionmode="Always" enableEventValidation="false" %>
The attribute ViewStateEncryptionMode has three values.
1) Auto
2) Always
3) Never
The default for ViewStateEncryptionMode is Auto.
We can also set its value in the web.config file as
<configuration>
<system.web>
<pages ViewStateEncryptionMode="Always" />
</system.web>
</configuration>