I'm receiving on mvc4 razor view cookie. looking on firebug I can see cookie raw data and json formatted data.
I've found that on razor side this should work
@Html.Raw(Json.Encode(object))
How can I on controller side decode raw cookie data to json to examine further.
Is there something like
Json.Encode(Request.Cookies["MyCookie"].Value); // this doesnt work
Suggest you use Newtonsoft.Json to convert JSON back and forth, it works great.
You can decode a cookie using below pattern:
JsonConvert.DeserializeObject(Request.Cookies["MyCookie"].Value);
HTH!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.