.Net Razor Ajax Post Get处理

Talk is cheap,Show me the code.

.cshtml

复制代码

  let pdata = { "weight": 50, "origin": originSel.value, "destination": destinationSel.value };
  let r = await axios.post("/search?handler=list" , pdata).catch(() => null);
  console.log(r);

复制代码

.cs 注意参数要加【FromBody】,get的话 OnGetList

复制代码

  public ActionResult OnPostList([FromBody]Ly.Model.FromBody.SearchRequestInfo requestInfo)
  {
    var list = _priceService.Search(requestInfo.Origin,requestInfo.Destination,requestInfo.Weight);
    return new JsonResult(list);
  }

复制代码
 

posted on 2024-04-26 10:20  kobe  阅读(10)  评论(0编辑  收藏  举报

导航