Hi friends,
I want to know that how can you detect if a ViewState has been tampered? How it will handle please explain?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gohil JayendrasinhPosted Mar 21, 2012, 2:01 AM
1. Use Encryption of ViewState content
2. Use the EnableViewStateMac property
To encrypt the contents of the ViewState, use the following in the machine.config file.
EnableViewState will only Encode the value, that will not solve our problem where as EnableViewStateMac will do actual encryprtion.
<%@ Page language="c#" Codebehind="TestForm.aspx.cs"AutoEventWireup="false" EnableViewStateMac="True" Inherits="TestForm" %>
in web.config
< pages ViewStateEncryptionMode="Always" />
if it's helpful to you then please check Accepted Asnwers
Thanks
Jignesh TrivediPosted Mar 21, 2012, 12:00 AM
The viewstate is signed with a machine key (default servers MAC). If your Application running on farm make sure to set the same machine key on all machines.
You can add encrypted checksum in the ViewState, and check whether it is still correct after the postback.
SenthilkumarPosted Mar 20, 2012, 10:07 AM
You can restrict the hackers to tampared the view state.
You can set this EnableViewStateMac="true" attribute in the page directive or web.config file.