ExtJS: how to return json success w/ data using asp.net mvc

前端 未结 3 1535
南旧
南旧 2020-12-29 14:57

I am trying to use ExtJS with Asp.Net MVC, and it is going fine so far. (Nice work on ExtJS) To make things easier, I need some help returning data from .net to ExtJS.

3条回答
  •  失恋的感觉
    2020-12-29 15:28

    Try this one...

    public JsonResult Index()
    {
        var json = new
        {
            success = true,
            data = from user in repository.FindAllUsers().AsQueryable()
                   select new
                   {
                       id = user.Id,
                       name = user.Name,
                       ...
                   }
        };
        return Json(json);
    }
    

提交回复
热议问题