In my CS file I'm executing the following and it works as expected.
using System.Web.Helpers;
String json = System.Web.Helpers.Json.Encode(null);
However, in my CSHTML file I'm executing the following, and here, I get an error about Json not being recognized in the context.
@{ Layout = null; }
@using TestService.ServiceReference;
@using System.Web.Helpers;
<!DOCTYPE html>
<html>
...
<script type="text/javascript">
var output3 = "! @Html.Raw(Json.Encode(ViewBag.MyArray))";
...
How can that be explained/remedied? Googling gave me nada, zero, ziltch...
Edit
I've added assemblies tag to my CONFIG file as suggested but the error I'm getting is that it's an unknown to the configuration. This is what my (root) CONFIG looks like.
<system.web>
<compilation debug="true" targetFramework="4.0" />
<assemblies>
<add assembly="System.Web.Helpers, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
...
However, I've noticed that I do have the following in the CONFIG file instead. I'm guessing it's equivalent. Is it?
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>