Pass multiple parameters in a POST API without using a DTO class in .Net Core MVC

后端 未结 5 1115
旧巷少年郎
旧巷少年郎 2021-02-15 16:53

I have an action on my web project which calls to an API

    [HttpPost]
    public async Task ExpireSurvey(int id)
    {
        var token =         


        
5条回答
  •  醉话见心
    2021-02-15 17:21

    Based on the answers above, I got the following code working. Hope this helps someone! (thanks to others of course for getting me on the right track)

    /// 
    /// Post api/dostuff/{id}
    [HttpPost]
    [Route("dostuff/{id}")]
    public async Task DoStuff([FromBody]Model model, int id)
    {
        // Both model and id are available for use!
    }
    

提交回复
热议问题