I have an incoming GET request as follows:
https://localhost:44329/api/scoInfo?activityId=1&studentId=1×tamp=1527357844844
How would I create an endpoint in ASP.net-core that would accept this request.
I have tried different versions of the following and nothing works:
[HttpGet("{activityId: int}/{studentid: int}/{timestamp: int}")]
[Route("api/ScoInfo/{activityId}/{studentid}/{timestamp}")]
Use [FromQuery]
to specify the exact binding source you want to apply.
//GET api/scoInfo?activityId=1&studentId=1×tamp=1527357844844
[HttpGet("api/scoinfo")]
public async Task<IActionResult> GetLearningTask(
[FromQuery]int activityId,
[FromQuery]int studentId,
[FromQuery]int timeStamp) {
//...
}
MVC will try to bind request data to the action parameters by name. MVC will look for values for each parameter using the parameter name and the names of its public settable properties.
Reference Model Binding in ASP.NET Core
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments