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

浪淘沙2个月前后端50
{
  "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 发送253短信

<form method="post">     <button type="submit...

asp.net core razor 一个页面多个提交

<form method="post">     <button type="submit...

asp.net core razor 一个页面,新增,列表,删除,修改等集大成操作

asp.net core razor 一个页面,新增,列表,删除,修改等集大成操作

一、界面二、razor代码@page @model xxtsoft.Web.Entry.Pages.sysadmins.stu.stu_bftz_addModel@{  &nb...

设置edge浏览器自动填充 input password值

<form autocomplete="off">    <input type="password" name=&quo...

asp.net core 中文 url 编码

 return Redirect("tj_send?fst=" + fst + "&rq1=" + rq1 + "&rq2=...

asp.net core SqlSugar 多库切换

  private readonly SqlSugar.ISqlSugarClient _db;     ...

发表评论    

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