FineUI 获取x_state并解析

        public JObject PostBackStates()
        {
            JObject xState = null;
            if (Page.IsPostBack)
            {
                string state = HttpContext.Current.Request.Form["X_STATE"];
                string xstateURI = HttpContext.Current.Request.Form["X_STATE_URI"];
                if (!String.IsNullOrEmpty(state))
                {
                    state = String.IsNullOrEmpty(xstateURI) ? DecodeFrom64(state) : HttpUtility.UrlDecode(state);
                }
                state = String.IsNullOrEmpty(state) ? "{}" : state;
                xState = JObject.Parse(state);
            }
            return xState;
        }

        private string DecodeFrom64(string encodedData)
        {
            byte[] encodedDataAsBytes = System.Convert.FromBase64String(encodedData);
            return System.Text.UTF8Encoding.UTF8.GetString(encodedDataAsBytes);
        }

        private string EncodeTo64(string toEncode)
        {
            byte[] toEncodeAsBytes = System.Text.UTF8Encoding.UTF8.GetBytes(toEncode);
            return System.Convert.ToBase64String(toEncodeAsBytes);
        }

 

posted @ 2013-11-04 16:35  黑冰.org  阅读(593)  评论(0编辑  收藏  举报