I am trying to call a Json.Encode(...)
method in MVC 4 and I'm getting an error: The name 'Json' does not exist in the current context.
I've tried adding System.Runtime.Serialization
namespace, which has Json
class, but this particular instance of Json
class doesn't have Encode
method.
What assembly am I missing here?
Here is my exact code:
{ url: '@Url.Action("DeleteDefinitionRule")', editData:
{ companyCode: 'LO', definitionID:@Html.Raw(Json.Encode(Model.DefinitionID)) } }
And now @Json.Encode should work.
Update
To be clear, even after you add the correct reference to your project, you still have to add this line at the top of your Razor page:
@using System.Web.Helpers;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With