I have an API endpoint that takes a query string parameter, but the value returned is always null, even when a value is passed.
This is the method in my Blazor web app:
public async Employee GetEmployee(EmployeeDetails details)
{
var qString = string.Empty;
if (details != null)
{
if (details.EmployeeId != null)
{
qString += "empId=" + details.EmployeeId;
var employee = await _httpClient.GetAsync($"api/EmployeeData/GetData?{qString}");
return employee;
}
}
}
I have the following endpoint in the employee data controller in the API:
public async Task<ActionResult<Employee>> GetData([FromQuery] string? Id)
{
// The value of query string Id is always null here.
}
Am I missing something? Could someone point me in the correct direction, please?
Thanks in advance
1