I'm writing an asp net core application. What I want to achieve is to read the model inside the view with Javascript. I found this code but when I run it i receive this error:
'IJsonHelper' does not contain a definition for 'Encode' and no extension method 'Encode' accepting a first argument of type 'IJsonHelper' could be found (are you missing a using directive or an assembly reference?)
how can i fix it?
controller
public async Task<IActionResult> Index()
{
return View(await _context.Bolla.ToListAsync());
}
view
@model IEnumerable<ps0001.Models.Bolla>
<script>
var bolla = @Html.Raw(Json.Encode(Model));
</script>