0

I am trying to using @Json.Encode in my project. My view won't pull the Json object.

I have version 2.0.0.0 of system.web.helpers referenced, and when I expand it, I can even see the Json class. I added system.web.helpers as a using statement and it still won't find the object?

I am trying to use @Json.Encode inside of a javascript statement. I already cleaned and rebuilt the project to. I tried removing and re-adding the reference, any other suggestions?

eaglei22
  • 2,589
  • 1
  • 38
  • 53
  • Possible duplicate of this http://stackoverflow.com/questions/12682128/mvc-4-assembly-reference-missing-for-json-encode – Tequila Dec 15 '15 at 14:57
  • ^^ I am referencing "System.Web.Helpers" which that was the selected solution. Which didn't work for me. – eaglei22 Dec 15 '15 at 15:00
  • Have you added `@using System.Web.Helpers;` at the top of your view? Or, try with `System.Web.Helpers.Json.Encode()` – Satpal Dec 15 '15 at 15:05
  • I have tried both and that did not work either. – eaglei22 Dec 15 '15 at 15:22
  • Remove your reference and re add it and see – Shyju Dec 15 '15 at 16:19
  • I had done that also, by removing the the reference and just re adding it from the .net library. That didn't work either. I did try it in the controller, and I can pull up Json there but the static method "Encode" will not show up.. Something is really odd, and this is a project I am modifying from another programmer. What is the best way to remove system.web.helpers and re-download it from NuGet? – eaglei22 Dec 15 '15 at 16:20

1 Answers1

0

I finally got it working. I am not sure what was wrong with the reference I was using, and this isn't really the solution I was looking for, but it works. I removed the reference to System.Web.Helpers and browsed another project that had a working copy and pointed it to that System.Web.Helpers.dll. Then in the properties (From Visual Studio 2010) of the reference, I I changed Copy Local attribute from False to True.

Hopefully a better answer is given at some point but this was a workable solution for me.

eaglei22
  • 2,589
  • 1
  • 38
  • 53