razor list string to javascript array code example
Example: viewdata array mvc razor javascript
// For ASP.NET
var monthLists = @Html.Raw(Json.Encode(ViewData["months"]));
// For ASP.NET CORE
var monthLists = @Html.Raw(Json.Serialize(ViewData["months"]));