How to parse objects from ViewBag to JavaScript?
问题 I am trying to parse an object from ViewBag to Javascript without luck. I have tried so far with jQuery/razor/mixed syntax...to no avail. When I tried with Json.Encode() , I get an "error not defined". Class class Story { public long Id {get;set;} public string Description{get;set;} } Controller [HttpGet] public IActionResult Index(Story _story) { List<Location> Locations = this.context.Locations.ToList(); ViewBag.story = _story; return View(context.Locations); } View $(document).ready