C#返回JSON格式数据


又类的属性生成json格式数据

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MV4项目学习.Controllers
{
    public class HlhController : Controller
    {
        // GET: Hlh
        public JsonResult Index()
        {
            ViewData["app"] = "mlh1421";
            ViewBag.name = "qwer";
            //return View();
            List<A> list = new List<A>();
            list.Add(new A { Name = "mlh", Age = 12 });

            return Json(list,JsonRequestBehavior.AllowGet);
        }
        public ActionResult Mlh()
        {
            return View("Show");
        }
    }
    class A
    {
        public string Name
        {
            get;set;
        } 
        public int Age
        {
            get;
            set;
        }
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM