Пример #1
0
        protected override void SavePageStateToPersistenceMedium(object viewState)
        {
            LosFormatter formatter = new LosFormatter();
            StringWriter writer    = new StringWriter();

            formatter.Serialize(writer, viewState);
            string viewStateString = writer.ToString();

            byte[] bytes = Convert.FromBase64String(viewStateString);
            bytes = ViewStateCompressor.Compress(bytes);
            ScriptManager.RegisterHiddenField(this, "__COMPRESSEDVIEWSTATE", Convert.ToBase64String(bytes));
        }
Пример #2
0
        protected override object LoadPageStateFromPersistenceMedium()
        {
            var viewState = Request.Form["__COMPRESSEDVIEWSTATE"];

            if (string.IsNullOrEmpty(viewState))
            {
                return(null);
            }

            try
            {
                byte[] bytes = Convert.FromBase64String(viewState);
                bytes = ViewStateCompressor.Decompress(bytes);
                var formatter = new LosFormatter();

                return(formatter.Deserialize(Convert.ToBase64String(bytes)));
            }
            catch (Exception)
            {
                return(null);
            }
        }