I'm just trying to get a JSON string from my controller (MVC3 using Razor syntax) in a client browser ...
In My Controller, I do this with a simple object (test) that contains an int and a list.
var jasonData = new JavaScriptSerializer().Serialize(test); ViewBag.JasonData = jasonData;
In the view, I do this:
<script type="text/javascript"> var initialData = @(ViewBag.JasonData); </script>
Visual Studio shows that the data looks great, but when it ends in the browser, it has escaping code around all the data that is not good.
&var initialData = {"DateId":32,"Scores&quo ....
It should be easy! What am I doing wrong?
Pablo source share