Exemplo n.º 1
0
        public void SaveTempData(ControllerContext controllerContext, IDictionary <String, Object> values)
        {
            //THIS WAS THE LAST CHANGE I DID TO THE CODE AFTER SAW IT WORKING (COOKIE WAS NOT BEIGN REMOVED HOWEVER)
            if (values.Count == 0)
            {
                // if we have no data then issue an expired cookie to clear the cookie
                IssueCookie(controllerContext, null);
            }

            // convert the temp data dictionary into json
            var value = Serialize(values);

            // compress the json (it really helps)
            //var Bytes = Compress(value);

            // issue the cookie
            IssueCookie(controllerContext, EncryptionService.Encrypt(value));
        }
Exemplo n.º 2
0
        public IDictionary <String, Object> LoadTempData(ControllerContext controllerContext)
        {
            // get the cookie
            var rawValue = GetCookieValue(controllerContext);

            if (rawValue == null)
            {
                return(null);
            }

            // verify and decrypt the value via the asp.net machine key
            var value = EncryptionService.Decrypt(rawValue);

            // decompress to json
            //value = Decompress(Bytes);

            // convert the json back to a dictionary
            return(JsonConvert.DeserializeObject <Dictionary <String, Object> >(value));
        }