I can pass a variable from MVC ASP.NET by using this :
var lastCategoryId = \'<%=Model.CS.LastSelectedCategory %>\';
This work fine
You need to format the array into a JavaScript array syntax.
var someArray = [<%= Model.SomeArray.Select(x => "'" + x +"'")
.Aggregate((x,y) => x + ", " + y); %>];
This will surround each entry by single quotes and then join them together with commas between square brackets.
Updated: removed extra parenthesis.