title: Could not load file or assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
body: <p>I am trying to develop a web application that displays some charts based on different data that is stored in a database. I found on different tutorials online that I should transfer the data from the controller to the view using a model and then to use Json.Encode for the data to be read correctly by my chart.
  First it didn't recognize Json.Encode method, so I had to use NuGet Packet Manager to install Microsoft.AspNet.WebPages and when I try to run the app, this error pops up.</p>
  <p>I am using .NET Core 5.0</p>
  <p>This is where the error comes in:</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  var chart = document.getElementById('pie').getContext('2d');
  
  var myChart = new Chart(chart, {
      type: 'pie',
      data : @Html.Raw(System.Web.Helpers.Json.Encode(Model.PieChartData)),
  });
  &lt;/script&gt;
  </code></pre>
  <p>This is how I build the model that is given to the view:</p>
  <pre><code>public PieChartVM GetPieChartData()
      {
          var model = new PieChartVM();
  
          var labels = new List&lt;string&gt;();
          labels.Add(&quot;Green&quot;);
          labels.Add(&quot;Blue&quot;);
          labels.Add(&quot;Gray&quot;);
          labels.Add(&quot;Purple&quot;);
  
          model.labels = labels;
  
          var dataset = new List&lt;PieChartChildVM&gt;();
          var childModel = new PieChartChildVM();
  
          var backgroundColorList = new List&lt;string&gt;();
          var dataList = new List&lt;int&gt;();
  
          foreach(var label in labels)
          {
              if (label == &quot;Green&quot;)
              {
                  backgroundColorList.Add(&quot;#2ecc71&quot;);
                  dataList.Add(12);
              }
              if (label == &quot;Blue&quot;)
              {
                  backgroundColorList.Add(&quot;#3498db&quot;);
                  dataList.Add(20);
              }
              if (label == &quot;Gray&quot;)
              {
                  backgroundColorList.Add(&quot;#95a5a6&quot;);
                  dataList.Add(18);
              }
              if (label == &quot;Purple&quot;)
              {
                  backgroundColorList.Add(&quot;#9b59b6&quot;);
                  dataList.Add(50);
              }
          }
  
          childModel.backgroundColor = backgroundColorList;
          childModel.data = dataList;
          dataset.Add(childModel);
          model.datasets = dataset;
  
          return model;
      }
  </code></pre>