title: Asp net core - from model to javascript
body: <p>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:</p>
  
  <blockquote>
    <p>'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?)</p>
  </blockquote>
  
  <p>how can i fix it?</p>
  
  <p><strong>controller</strong></p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Index()
  {
      return View(await _context.Bolla.ToListAsync());
  }
  </code></pre>
  
  <p><strong>view</strong></p>
  
  <pre><code>@model IEnumerable&lt;ps0001.Models.Bolla&gt;
  
  &lt;script&gt;
      var bolla = @Html.Raw(Json.Encode(Model));
  &lt;/script&gt;
  </code></pre>