Reputation: 87
I have tried to hit the action method with this url in the postman and it's not reading the value for employeeNumber from [FromRoute] Postman request: https://localhost:44309/Department/9002069554
[HttpGet("{employeeNumber}", Name = "Get")]
public async Task<IActionResult> Get([FromRoute] Employee employeeNumber)
{
//
}
public class Employee
{
[BindRequired]
[FromRoute]
public string employeeNumber { get; set; }
}
Upvotes: 0
Views: 835
Reputation: 8469
The accept parameter can't be same as the property name, you should change it.
[HttpGet("{employeeNumber}", Name = "Get")]
public async Task<IActionResult> Get([FromRoute] Employee employee)
{
//
}
Upvotes: 1