mvc传递json数据到view简单实例
作者:互联网
基于extjs4.2
controller
//存储数据的类
public class DataLink {
public string Name { get; set; }
public string Address { get; set; }
public int Age { get; set; }
}
public ActionResult MessageBack(string username)
{
//声明泛型
List<DataLink> resultData = new List<DataLink>();
//存储数据到对象中
resultData.Add(new DataLink() { Name = "tetse", Age = 19, Address = "ly" });
//把对象序列化为string
string rs = Newtonsoft.Json.JsonConvert.SerializeObject(resultData);
//返回前端
return Content(rs);
}
标签:DataLink,set,string,get,resultData,json,mvc,public,view 来源: https://www.cnblogs.com/LY-CS/p/12739324.html