December 2019
Intermediate to advanced
598 pages
12h 21m
English
Let's implement an action method for posting a question:
[HttpPost]public ActionResult<QuestionGetSingleResponse> PostQuestion(QuestionPostRequest questionPostRequest){ // TODO - call the data repository to save the question // TODO - return HTTP status code 201}
Note that we use an HttpPost attribute to tell ASP.NET Core that this method handles HTTP POST requests.
Note that the method parameter type is a class. Earlier, in the Extending the GetQuestions action method for searching section, we introduced ourselves to model binding and explained how it maps data from an HTTP request to method parameters. Well, model binding can map data from the HTTP ...
Read now
Unlock full access