Ejemplo n.º 1
0
        public void encodeButtonPressed(object sender, EventArgs e)
        {
            try
            {
                viewState = ViewState.newViewStateFromXMLString(myControl.viewStateXMLEncodedTextBox.Text);
                if (viewState.m_MACProtected == true)
                {
                    myControl.errorLabel.Text = "Warning: Reencoded ViewState does not contain MAC protection";
                }
                else
                {
                    myControl.errorLabel.Text = "";
                }
                myControl.viewStateEncodedTextBox.Text = viewState.viewStateBase64;
                myControl.MACValueLabel.Text = viewState.MAC;
                myControl.versionValueLabel.Text = viewState.versionString;
                String viewStateString = getViewStateString(bodyString);
                m_entityBody = System.Text.Encoding.UTF8.GetBytes(bodyString.Replace(viewStateString, HttpUtility.UrlEncode(myControl.viewStateEncodedTextBox.Text)));
                m_bDirty = true;
            }
            catch (Exception)
            {
                myControl.errorLabel.Text = "Error: Cannot encode malformed XML";
                myControl.MACValueLabel.Text = "Unknown";
                myControl.versionValueLabel.Text = "Unknown";

            }
        }
Ejemplo n.º 2
0
        public void decodeButtonPressed(object sender, EventArgs e)
        {
            try
            {
                myControl.errorLabel.Text = "";
                viewState = ViewState.newViewStateFromBase64String(myControl.viewStateEncodedTextBox.Text);
                String viewStateString = getViewStateString(bodyString);
                myControl.viewStateXMLEncodedTextBox.Text = viewState.viewStateXML;
                myControl.MACValueLabel.Text = viewState.MAC;
                myControl.versionValueLabel.Text = viewState.versionString;
                m_entityBody = System.Text.Encoding.UTF8.GetBytes(bodyString.Replace(viewStateString, HttpUtility.UrlEncode(myControl.viewStateEncodedTextBox.Text)));
                m_bDirty = true;
            }
            catch (Exception)
            {
                myControl.errorLabel.Text = "Error: Cannot decode malformed, encrypted, or unsupported ViewState";
                myControl.MACValueLabel.Text = "Unknown";
                myControl.versionValueLabel.Text = "Unknown";

            }
        }