Click here to Skip to main content
15,916,318 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
how can we decrypt the view state in asp.net ?

asp.net interview question
Posted
Updated 15-May-22 3:08am
Comments
[no name] 20-Aug-12 9:56am    
www.google.com

 
Share this answer
 
SQL
I like this view state decoder. Very easy to use.

http://ignatu.co.uk/ViewStateDecoder.aspx
 
Share this answer
 
The question is very tricky.
Before I go into details, first need to know what is view state.
In brief, ViewState is a Base64 encoded string and is not readable by the human eye. Though it is not difficult to decode is and read the view state information.

Open any page in a browser, go to the source page, copy the view state value in the clipboard.

Now create a page and add a hiddencontrol,

<asp:textbox id="txt_viewstate" value="{paste from clipboard}" runat="server" xmlns:asp="#unknown"></asp:textbox>


Now add a button control and write the button event

//code behind    
protected void Button1_Click(object sender, EventArgs e)
    {
        byte[] decode = Convert.FromBase64String(txt_viewstate.Text);
        Response.Write(System.Text.Encoding.ASCII.GetString(decode));
    }


Hope this helps.
cheers
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900