I’m trying to pass my MVC3 model into a script block on the client. Here’s my approach (Razor view):
<script type="text/javascript">
var items = @( Json.Encode(Model) );
</script>
Here “Model” is just an array of strings. This renders almost correctly, but the encoding is funny:
var items = ["item1","item2","item3];
How can I fix this?
The @ sign html encodes your output if its not an MvcString – so use Html.Raw