Hi friends,
I want to know that how can you detect if a ViewState has been tampered? How it will handle please explain?
Tampering of ViewState
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Mar 20, 2012, 6:07 AM EDT
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.
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 20, 2012, 8:00 PM EDT
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.
Gohil JayendrasinhRank #490 · 5K reputationPosted Mar 20, 2012, 10:01 PM EDT
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