asp.net core furion 前端传入json,后端api接入并角析

浪淘沙2周前后端15
{
  "result": {
    "cover": {
      "title": "标题",
      "img": "https://localhost:5001/UpLoadFiels/pic.png",
      "link": "",
      "url": "ts_nr"
    },
    "list": [
      {
        "title": "标题1",
        "img": "https://localhost:5001/UpLoadFiels/pic.png",
        "link": "",
        "url": "ts_nr"
      },
{
        "title": "标题2",
        "img": "https://localhost:5001/UpLoadFiels/pic.png",
        "link": "",
        "url": "ts_nr"
      }
  ]
  },
  "ts": {
    "rs": "600",
    "tpe": "定时推送",
    "jhsj": "2026-03-04 00:00:00",
    "title": "1",
    "bz": "1"
  }
}
    [NonUnify]
    [Route("Add")]
    [HttpPost]
    public async Task<object> Add([FromBody] dynamic json)
    {

       
       
        var ts = json.ts;
        var rs = ts.rs;

        var result = json.result;
        var cover= result.cover;
        var title = cover.title;
        //数组
        var list = json.result.list;
        var listcount = list.Count;
        var lstr = "";
        foreach (var item in list)
        {
            string title1 = item.title;
            string img1 = item.img;

            lstr+= "标题:" + title1 + ",图片:" + img1 + "\n";
        }
        return lstr;
    }
    #endregion

}
 fetch('/api/tsExt/Add', {
     method: 'POST',
     headers: { 'Content-Type': 'application/json' },
     body: JSON.stringify(finalData)
 })
 .then(res => res.json())
 .then(res => {
     console.log(res);
   
 });


相关文章

asp.net core Razor 部门视图Partial Views 用法

1、在/Pages/Shared/目录下创建设视图文件 _top.cshtml2、在razor页面中进行引用@await Html.PartialAsync("_top&...

常用查询

 var dt = _db.SqlQueryable<object>("select * from mszs...

visual studio 配置 asp.net core razor .shtml文件类型和包含,支持跨平台通用

自己在 ASP.NET Core 里写 Middleware 解析 SSI自己在 ASP.NET Core 里写 Middleware 解析 ...

asp.net core 获取url及参数

  var url = $"{Request.Scheme}://{Request.Host}{Request.Path}{Request....

echarts获取点击事件

  myChart.on('click', (params) => {      // 检查是否点击了系列数据   ...

asp.net core Task 返回类型

public async Task<IActionResult> OnPostAsync()   {   &nbs...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。