ScriptIgnore ASP 6

I am trying to ignore a field when I convert my object to json string. I saw on the Internet that I should use [ScriptIgnore] on my field. But I can not find a way to import System.Web.Script ...

I use this:

"dependencies": {
"AutoMapper": "4.2.1",
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},

Is it because it is incompatible due to MVC 6?

+4
source share
3 answers

Right-click on "Links" in the solution explorer, then select "Add Links .." - you need to add System.Web.ExtensionsAssemblies - DNX 4.5.1 to your solution.

, DNX Core 5.0, , . , "" project.json.

 // comment out or delete.
 "dnxcore50": { } 

, MSDN, , .

+1

System.Web, , :

MVC , [JsonIgnore] ( Newtonsoft.Json) [ScriptIgnore].

, , : fooobar.com/questions/1640384/...

+7

Newtonsoft.Json;

Newtonsoft.Json.Converters;

{

public int Id {get; ; }

public int Number {get; ; }

public int? BookId {get; ; }

[JsonProperty (ReferenceLoopHandling = ReferenceLoopHandling.Ignore)]

{get; ; }

}

////////////////

{

public int Id {get; ; }

public string {get; ; }

ICollection {get; set;}

}

+1

All Articles