Returning JSON from a JsonResult method in MVC controller

后端 未结 5 1385
温柔的废话
温柔的废话 2021-01-04 18:06

I am trying to populate a ComboBox (Telerik RAD COmboBox) in a test ASP.NET MVC3 app.

I have defined the ComboBox on my ASPX page and in the controller I have define

5条回答
  •  猫巷女王i
    2021-01-04 18:41

    In MVC 5 and possibly below you can do something like this:

                var dict = new Dictionary
                {
                    { "name", "Foobar" },
                    { "url", "admin@foobar.com" }
                };
    
                var json = new JsonResult()
                {
                    Data = dict
                };
    

提交回复
热议问题