I'm trying to convert my view model data to JSON, however, I can't seem to access @Json.Encode
. I've added the System.Web.Helpers
reference, but that didn't work. What am I doing wrong?
Put this at the top of your view
@using Newtonsoft.Json
And then you can do this
@Html.Raw(@JsonConvert.SerializeObject(ViewBag.MyStuff))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With