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

浪淘沙5个月前后端102
{
  "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 onpost

不管 OnGet 填充多少东西OnPost 必须再填一次因为 Razor Pages 不会“记住” ViewModelPOST 后是重新执行一个请求,Model 全部重新创建。不像 WebForms,...

asp.net core 取得页面form中所有表单值

public IActionResult OnPostSubmit()         { &n...

asp.net core HttpClient post ,get

1、postusing System.Net.Http.Headers; using System.Text; using System.Text.Json;...

ubuntu 删除asp.net core 8.0

1. 查找已安装的 ASP.NET Core 8.0 版本dotnet --list-runtimes dotnet --list-sdks2. 删除 ASP.NET Core...

DBeaver连接oracle 下载驱动报错

https://blog.csdn.net/weixin_45764765/article/details/124327194...

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

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

发表评论    

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