最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

未設(shè)置[FromForm]致使未能接收到值

2022-01-01 14:45 作者:Tuple_元組  | 我要投稿

環(huán)境:前端是微信小程序,后端是.net6 webApi

前端代碼:

wx.request({
url:?app.globalData.serverHttpUrl?+?"/Comment/",
?method:?"DELETE",
?data:?{CommentId:?e.currentTarget.dataset.commentid,?},
header:?{'content-type':?'application/x-www-form-urlencoded'},
success:?(res)?=>?{}
})

后端代碼:

[HttpDelete]
public async Task<JsonResult> DeleteAsync([FromForm] int CommentId)
?{
? ? if (await _DataCommentRep.DelOneByIdAsync(CommentId) < 1){
? ? ? ?return new JsonResult(new VMResult<string>() { ResultCode = -1, ResultMsg = "S:刪除失敗", ResultEntity = null });?}
? ? ??return new JsonResult(new VMResult<string>() { ResultCode = 0, ResultMsg = "S:刪除成功", ResultEntity = null });
??}

注:如后端不使用 “[FromForm]” 則?CommentId 值始終為 0 即取不到值。

此外,需注意后端為 DELETE或GET時(shí),前端如不使用URL傳值的方式,應(yīng)設(shè)'content-type':?'application/x-www-form-urlencoded'



未設(shè)置[FromForm]致使未能接收到值的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
航空| 刚察县| 类乌齐县| 东乡| 刚察县| 封开县| 甘洛县| 巴楚县| 家居| 瑞丽市| 镇康县| 城口县| 南雄市| 天门市| 尤溪县| 双峰县| 全州县| 沂南县| 澄迈县| 石台县| 邹平县| 绥棱县| 陈巴尔虎旗| 焦作市| 丰镇市| 赤水市| 新巴尔虎左旗| 景宁| 东方市| 曲靖市| 铁力市| 房山区| 安陆市| 延边| 收藏| 军事| 微山县| 东丽区| 亳州市| 安新县| 柘荣县|