c# array assigned to javascript array in razor page 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"]));