我正在从MVC控制器操作返回一个JsonResult,并且一直试图删除一个属性,但没有太多乐趣。
return Json(db.Pages.ToList(), JsonRequestBehavior.AllowGet);
我试着用
[IgnoreDataMember]
属性,并在类的其他属性上使用[DataContract]和[DataMember]属性,但这似乎被忽略了。
我在这里找到了一篇文章,其中指出以这种方式返回json将使用JavaScriptSerializer,我尝试使用[ScriptIgnore],但vs2010没有将其识别为有效属性http://teamezy.blogspot.com/2008/12/making-jsonresult-in-mvc-ignore.html
我是否需要以不同的方式返回数据才能使IgnoreDataMember或DataContract/DataMember的东西正常工作?