将架构名称添加到对象

时间:2016-05-13 16:41:54

标签: c# asp.net-web-api kendo-ui

使用kendo,我需要通过此对象将服务器错误发送回客户端:

 public class callResult
    {
        public bool success { get; set; }
        public string message { get; set; }
        public int returnedID { get; set; }

    }

并希望返回对象返回客户端,看起来像这样 "错误:{成功:错误,消息:'无效代码'}"

但是当我像这样从服务中返回对象时

 return Json (error, JsonRequestBehavior.AllowGet);

我的架构"错误"没有被发送,只是对象的属性。

如何向我的对象添加架构/名称?

1 个答案:

答案 0 :(得分:1)

您可以修复json结果,例如:

return Json(new {error = errorResult}, JsonRequestBehavior.AllowGet);
相关问题