Can't get HTTP PUT request to work in ASP.NET Core

前端 未结 3 802
萌比男神i
萌比男神i 2021-01-25 08:22

I\'m trying to update an entry in the game table. However, my PUT request in ASP.NET never seems to trigger, and I can\'t figure out why.

This is controller

3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-25 09:23

    Can you modify your defining route just like

    [Route("game")]
    [HttpPut]
    public IActionResult updateGame([FromBody]Game update)
    {
       //your code
    }
    

    And call from angular like

    putGame(game:Game){
        return this._http.put(this.url + "game", game);
    }
    

    you can receive gameid from game object so don't need from url

提交回复
热议问题