后端是C#.Net客户端是JavaScript 我正在对BE执行ajax调用,并且我返回一个包含成员的对象。 当我在BE上调试时,我在发送响应时看到了所需的成员。 问题是在ajax回调中这个成员丢失了!
可能是什么问题?
调查班:
[Serializable]
public abstract partial class Survey : BaseClass, IInterface1, IInterface1
{
[JsonIgnore]
public List<Rule> Rules
{
get { return m_rules; }
set
{
m_rules = value;
if (m_rules != null)
{
foreach (SurveyRule rule in m_rules)
{
rule.EnclosingEntity = this;
}
}
}
}
}
BE代码 - 调试时我看到会员&#34;规则&#34;在调查
return Request.CreateResponse(HttpStatusCode.OK, survey);
客户代码:
_api.myAjaxCall(par1, par2, function (survey) {
if (callBack) // No Rules member on survey! everything else is there!
callBack(data);
});
答案 0 :(得分:3)
[JsonIgnore]
属性导致序列化以排除此属性。删除此属性,您的属性将被序列化。