我如何prevent JSON序列在ASP.NET MVC? [英] How do I prevent JSON serialization in ASP.NET MVC?

查看:120
本文介绍了我如何prevent JSON序列在ASP.NET MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发一个ASP.NET MVC应用程序,我发现了几个地方,我JsonResult动作抛出一个异常,而序列化对象时检测到循环引用。

While developing an ASP.NET MVC app, I'm finding a few places where my JsonResult actions throw an exception "A circular reference was detected while serializing an object".

现在,我删除涉嫌侵权的引用,但最好我想简单地标记属性使得JSON序列忽略它。

For now, I'm removing the references in question, but ideally I'd like to simply mark the property such that the JSON serializer ignores it.

任何人都可以建议我怎么可以这样做?

Can anyone suggest how I might do this?

推荐答案

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.script.serialization.scriptignoreattribute.aspx\">[ScriptIgnore]的的为你工作。

这篇关于我如何prevent JSON序列在ASP.NET MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆